PHP 实现百度收录批量查询

学习笔记 马富天 2017-08-27 16:31:01 140 0

【摘要】作为一名站长,我觉得大家都是比较关注自己的网页收录情况的,总会隔三差五的看看自己发表的文章有没有被百度收录呀,然后但是假如发布的文章数量比较多的时候查询起来就会比较麻烦,所有很有必要写一个小脚本程序来自己实现百度收录的批量查询。本文给出完整源代码。

首先是查询页面的完整源代码,大家可以直接将下面的代码复制到自己的 php 文件中即可,如下所示:

  1. <!DOCTYPE html>
  2. <html>
  3. 	<head>
  4. 		<meta charset="utf-8" />
  5. 		<meta name="keywords" content="百度收录批量查询,百度收录查询,外链批量查询,长尾关键词排名查询,百度排名查询,马富天博客" />
  6. 		<meta name="description" content="这是一款提供网络推广和网站推广人员跟踪外链效果和外推效果的强力工具,支持外链百度收录批量查询以及长尾关键词百度排名查询的功能,希望大家多提宝贵意见!" />
  7. 		<title>百度收录批量查询_外链收录批量查询_网站收录批量查询_马富天博客</title>
  8. 		<style type="text/css">
  9. 			*{margin:0;padding:0;font-size:12px;}
  10. 			.wrap{width:560px;height:auto;padding:20px 260px;margin:20px auto;background:#cdecde;border-radius:4px;}
  11. 			.box{background:#fff;border:#3c3c3c 1px solid;width:380px;height:160px;line-height:22px;padding:15px;}
  12. 			.input{width:300px;}
  13. 			h1{color:#254456;line-height:60px;font-size:20px;text-align:center;}
  14. 			p{line-height:24px;}
  15. 		</style>
  16. 	</head>
  17. 	<body>
  18. 		<div class="wrap">
  19. 			<h1>百度收录批量查询_马富天博客</h1>
  20. 			<?php
  21. 				if(isset($_POST["tj"]))
  22. 				{
  23. 					$ww1 = $_POST["link_f"];
  24. 				}else{
  25. 					$ww1 = "links.txt";
  26. 				}
  27. 				$ww = $ww1;
  28. 			?>
  29. 			<form method="post" action="">
  30. 				你的TXT链接文件地址:
  31. 				<input name="link_f" class="input" value="<?php echo $ww;?>" />
  32. 				<input type="submit" value=" 提 交 " name="tj" />
  33. 			</form>
  34. 			<p>TXT文本格式如下,一行一个;本地文件不行奥。</p>
  35. 			<div class="box">
  36. 				<p>http://www.mafutian.net/</p>
  37. 				<p>http://www.mafutian.net/5.html</p>
  38. 				<p>http://www.mafutian.net/100.html</p>
  39. 			</div>
  40. 			<?php
  41. 				if($ww!="")
  42. 				{
  43. 					site($ww);
  44. 				}
  45. 				function site($aa)
  46. 				{
  47. 					try 
  48. 					{
  49. 						$file = @fopen($aa,"r");
  50. 					}catch(Exception $e) 
  51. 					{
  52. 						die($e);
  53. 					}
  54. 					
  55. 					$urls=array();
  56. 					$i=0;$y=0;$w=0;$s=0;$num=count($urls);
  57. 					while(!@feof($file))
  58. 					{
  59. 						$urls[$i] = @fgets($file);
  60. 						$i++;
  61. 					}
  62. 					@fclose($file);
  63. 					$urls = array_filter($urls);
  64. 					echo "<br /><div id='asd'>共有 ".count($urls)." 条</div><br /><hr /><br />";
  65. 					foreach($urls as $line)
  66. 					{
  67. 						echo "<p>";
  68. 						$arr = checkBaidu($line);
  69. 						if($arr == "1")
  70. 						{
  71. 							$qwer = "<span style='color:green;'>已收录</span>";
  72. 							$y++;$s++;
  73. 						}else
  74. 						{
  75. 							$qwer = "<span style='color:red;'>未收录</span>";
  76. 							$w++;$s++;
  77. 						}
  78. 						echo $line."\t".$qwer; 
  79. 						echo "</p>";
  80. 					}
  81. 					echo "<br /><hr /><br /><div id='asd'>共有 ".count($urls)." 条,已经查询 ".$s." 条,已收录 ".$y." 条,未收录 ".$w." 条,收录率是".round($y/$s*100,2)."%。</div><br />";
  82. 				}
  83. 				function checkBaidu($ur) 
  84. 				{ 
  85. 				    $ur = 'http://www.baidu.com/s?wd=' . urlencode($ur); 
  86. 				    $curl = curl_init(); 
  87. 				    curl_setopt($curl, CURLOPT_URL, $ur); 
  88. 				    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
  89. 				    $rs = curl_exec($curl); 
  90. 				    curl_close($curl); 
  91. 				    if (!strpos($rs, '没有找到'))
  92. 				    {
  93. 				        return 1; 
  94. 				    } else { 
  95. 				        return -1; 
  96. 				    } 
  97. 				}
  98. 			?>
  99. 		</div>
  100. 	</body>
  101. </html>

然后是 links.txt 文件,里面写的内容是:

  1. http://www.mafutian.net
  2. http://www.mafutian.net/5.html
  3. http://www.mafutian.net/100.html

这样一个完整的 php 实现百度查询收录情况的批量查询工具就完成啦~~给大家看看程序执行的结果截图:

请输入图片名称

觉得喜欢的话,可以给我点个赞哦~

http://www.mafutian.net/tool/shoulu/index.php

版权归 马富天个人博客 所有

本文标题:《PHP 实现百度收录批量查询》

本文链接地址:http://www.mafutian.com/311.html

转载请务必注明出处,小生将不胜感激,谢谢! 喜欢本文或觉得本文对您有帮助,请分享给您的朋友 ^_^

0

0

上一篇《 跨站脚本 XSS 漏洞检测方法研究的至今 2017 年 8 月的所有相关论文 》 下一篇《 PHP 使用 strpos() 函数来判断字符串中是否包含有某一字符串 》

暂无评论

评论审核未开启
表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情 表情
验证码

TOP10

  • 浏览最多
  • 评论最多