博主辛苦了,我要打赏银两给博主,犒劳犒劳站长。
【摘要】作为一名站长,我觉得大家都是比较关注自己的网页收录情况的,总会隔三差五的看看自己发表的文章有没有被百度收录呀,然后但是假如发布的文章数量比较多的时候查询起来就会比较麻烦,所有很有必要写一个小脚本程序来自己实现百度收录的批量查询。本文给出完整源代码。
首先是查询页面的完整源代码,大家可以直接将下面的代码复制到自己的 php 文件中即可,如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="keywords" content="百度收录批量查询,百度收录查询,外链批量查询,长尾关键词排名查询,百度排名查询,马富天博客" />
<meta name="description" content="这是一款提供网络推广和网站推广人员跟踪外链效果和外推效果的强力工具,支持外链百度收录批量查询以及长尾关键词百度排名查询的功能,希望大家多提宝贵意见!" />
<title>百度收录批量查询_外链收录批量查询_网站收录批量查询_马富天博客</title>
<style type="text/css">
*{margin:0;padding:0;font-size:12px;}
.wrap{width:560px;height:auto;padding:20px 260px;margin:20px auto;background:#cdecde;border-radius:4px;}
.box{background:#fff;border:#3c3c3c 1px solid;width:380px;height:160px;line-height:22px;padding:15px;}
.input{width:300px;}
h1{color:#254456;line-height:60px;font-size:20px;text-align:center;}
p{line-height:24px;}
</style>
</head>
<body>
<div class="wrap">
<h1>百度收录批量查询_马富天博客</h1>
<?php
if(isset($_POST["tj"]))
{
$ww1 = $_POST["link_f"];
}else{
$ww1 = "links.txt";
}
$ww = $ww1;
?>
<form method="post" action="">
你的TXT链接文件地址:
<input name="link_f" class="input" value="<?php echo $ww;?>" />
<input type="submit" value=" 提 交 " name="tj" />
</form>
<p>TXT文本格式如下,一行一个;本地文件不行奥。</p>
<div class="box">
<p>http://www.mafutian.net/</p>
<p>http://www.mafutian.net/5.html</p>
<p>http://www.mafutian.net/100.html</p>
</div>
<?php
if($ww!="")
{
site($ww);
}
function site($aa)
{
try
{
$file = @fopen($aa,"r");
}catch(Exception $e)
{
die($e);
}
$urls=array();
$i=0;$y=0;$w=0;$s=0;$num=count($urls);
while(!@feof($file))
{
$urls[$i] = @fgets($file);
$i++;
}
@fclose($file);
$urls = array_filter($urls);
echo "<br /><div id='asd'>共有 ".count($urls)." 条</div><br /><hr /><br />";
foreach($urls as $line)
{
echo "<p>";
$arr = checkBaidu($line);
if($arr == "1")
{
$qwer = "<span style='color:green;'>已收录</span>";
$y++;$s++;
}else
{
$qwer = "<span style='color:red;'>未收录</span>";
$w++;$s++;
}
echo $line."\t".$qwer;
echo "</p>";
}
echo "<br /><hr /><br /><div id='asd'>共有 ".count($urls)." 条,已经查询 ".$s." 条,已收录 ".$y." 条,未收录 ".$w." 条,收录率是".round($y/$s*100,2)."%。</div><br />";
}
function checkBaidu($ur)
{
$ur = 'http://www.baidu.com/s?wd=' . urlencode($ur);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $ur);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$rs = curl_exec($curl);
curl_close($curl);
if (!strpos($rs, '没有找到'))
{
return 1;
} else {
return -1;
}
}
?>
</div>
</body>
</html>
然后是 links.txt 文件,里面写的内容是:
http://www.mafutian.net
http://www.mafutian.net/5.html
http://www.mafutian.net/100.html
这样一个完整的 php 实现百度查询收录情况的批量查询工具就完成啦~~给大家看看程序执行的结果截图:
觉得喜欢的话,可以给我点个赞哦~
http://www.mafutian.net/tool/shoulu/index.php版权归 马富天个人博客 所有
本文标题:《PHP 实现百度收录批量查询》
本文链接地址:http://www.mafutian.com/311.html
转载请务必注明出处,小生将不胜感激,谢谢! 喜欢本文或觉得本文对您有帮助,请分享给您的朋友 ^_^
顶0
踩0
评论审核未开启 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
||