• 凉风有兴,秋月无边, 亏我思娇的情绪好比度日如年。
  • 虽然我不是玉树临风,潇洒倜傥, 可是我有我广阔的胸襟,加强健的臂腕!

phpcms 百度查询是否收录.免插件版免费分享

技术笔记 villain 5个月前 (07-10) 98次浏览 已收录 0个评论

直接上代码.直接保存成baidu.php 然后访问就可以了  可以查最近3天的更新文章以及百度是否收录

<!DOCTYPE html PUBliC "-//W3C//dtD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/dtD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><a href="http://www.1004619.com/tag/%e7%99%be%e5%ba%a6%e6%94%b6%e5%bd%95/" title="查看更多关于百度收录的文章" target="_blank">百度收录</a></title>
<style type="text/css">
*{margin:0;padding:0}
 body{font-size:14px;line-height:25px;}
 div{padding:15px;}
 a:link, a:visited{text-decoration:none;color:#333;}
 a:hover{color:#f60;}
</style>
</head>

<body>
<div style="">
<?php 
$shijian = $_GET["shijian"];
if($shijian>0)
{
  $riqi = date("Y-m-d",strtotime("-$shijian day"));
}
else
{
  $riqi = date("Y-m-d",time());
}


$db_host = "localhost"; // 数据库服务器 'localhost'
$db_user = "root";  //mysql用户名
$db_pass = "root"; //mysql 密码
$db_name = "mysql"; //数据库名称
$db = mysql_connect($db_host,$db_user,$db_pass); 
mysql_select_db ($db_name) or die ("Cannot connect to database"); 
mysql_query("SET NAMES 'UTF8'"); 

$sql1="select FROM_UNIXTIME(`inputtime`, '%Y-%m-%d') as pubtime1, count(*) as cnt1 from v9_news  where `status`='99' and  FROM_UNIXTIME(`inputtime`, '%Y-%m-%d')='$riqi'";
$result1 = mysql_query($sql1); 

while($r1=mysql_fetch_array($result1)) 
{
	$output.=$riqi." 发布:<font color='#ff6600'><b>".$r1["cnt1"]."</b></font> 篇";
}

//查询今日<a href="http://www.1004619.com/tag/%e7%99%be%e5%ba%a6%e6%94%b6%e5%bd%95/" title="查看更多关于百度收录的文章" target="_blank">百度收录</a>
$sqlj="select id,title,url from v9_news  where `status`='99' and  FROM_UNIXTIME(`inputtime`, '%Y-%m-%d')='$riqi' order by id desc";
$resultj = mysql_query($sqlj); 
$jiz = 0;
while($rj=mysql_fetch_array($resultj)) {
  if(baidu($rj["url"]))
  {
       $shou = "<font color='red'>已收录</font>";
	   $jiz++;
  }
  else
 {
       $shou = "<font color='blue'>未收录</font>";
  }
  echo $rj["id"]." <a href='".$rj["url"]."' target='_blank'>".$rj["title"]."</a>  [<a href='http://www.baidu.com/s?wd=".$rj["url"]."' target='_blank'>".$shou."</a>]<br />";
}

$qian = $shijian+1; $hou = $shijian-1; if($hou<0)$hou=0;
echo "<br />".$output."文章,收录 <font color='#ff6600'><b>".$jiz."</b></font> 篇文章<br /><a href='?shijian=".$qian."'><< 查看前一天</a> <a href='?shijian=0'>查看今天</a> <a href='?shijian=".$hou."'>查看后一天 >></a>";


$sql="select FROM_UNIXTIME(`inputtime`, '%Y-%m-%d') as pubtime, count(*) as cnt from v9_news  where `status`='1' group by FROM_UNIXTIME(`inputtime`, '%Y-%m-%d')";
$result = mysql_query($sql); 

function baidu($url=""){
   $url="http://www.baidu.com/s?wd=".$url;
   $html=htmlspecialchars(fcontents($url)); 

   /*
   if(preg_match("/很抱歉/i", $html, $matches)){
     return 0;
   } else {
     return 1;
   }

   //strpos
   //stristr
   */
   $zifu = "很抱歉";
   if(strstr($html,$zifu))
   {
       return 0;
   }
   else
   {
       return 1;
   }
}

//获取网页内容函数
function fcontents( $url, $timeout = 5, $referer = "" )
{
		$bits = @parse_url( $url );
		if ( !$bits[host] )
		{
				return "";
		}
		if ( $bits[port] )
		{
				$port = intval( $bits[port] );
		}
		else
		{
				$port = $bits[scheme] == "https" ? 443 : 80;
		}
		$portq = $port == 80 ? "" : ":{$port}";
		$stime = time( );
		$fp = @fsockopen( $bits[host], $port, $errno, $errstr, $timeout );
		if ( !$fp )
		{
				return "";
		}
		else
		{
				$stime = time( ) - $stime;
				$timeout = $timeout - $stime;
				if ( $timeout < 1 )
				{
						$timeout = 1;
				}
				stream_set_timeout( $fp, $timeout );
				if ( !$referer )
				{
						$referer = $bits[scheme]."://".$bits[host]."/";
				}
				$path = $bits[path] ? $bits[path] : "/";
				if ( $bits[query] )
				{
						$path .= "?".$bits[query];
				}
				$out = "GET {$path} HTTP/1.0\r\n";
				$out .= "Host: {$bits[host]}{$portq}\r\n";
				$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n";
				$out .= "Accept: */*\r\n";
				$out .= "Accept-Language: zh-cn\r\n";
				$out .= "Accept-Encoding: identity\r\n";
				$out .= "Referer: {$referer}\r\n";
				$out .= "Connection: Close\r\n\r\n";
				fputs( $fp, $out );
				$data = "";
				$inHeaders = true;
				while ( $line = @fgets( $fp, 2048 ) )
				{
						if ( $inHeaders )
						{
								$line = trim( $line );
								if ( empty( $line ) )
								{
										$inHeaders = false;
								}
								continue;
						}
						$data .= $line;
				}
				fclose( $fp );
				return $data;
		}
}

?>


</div>
</body>
</html>


Villain博客 , 版权所有丨如有问题请联系客服QQ:1004619丨
转载请注明phpcms 百度查询是否收录.免插件版免费分享
喜欢 (0)
[gqakcom@126.com]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址