代码可以用来批量查询网站中所有文章的收录情况,如果收录了就显示百度已收录如果没收录就显示百度未收录,避免每次都要输入网址去site了省了大量的时间。

代码如下:(如果直接复制不能用的话本页底部有下载地址)
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <!--by:森林之家(www.foresthouse.cn)--> <meta name="keywords" content="百度收录批量查询" /> <meta name="description" content="百度收录批量查询php源码" /> <title>百度收录批量查询_网站收录批量查询_php源码</title> <style type="text/css"> <style>html{background-color: #081832;font-family: 'Microsoft Yahei',Tahoma, Arial;}table{width: 100%;}table tr{background-color: #034c6a;color: #25f3e6;}table td:hover{background:#081832;}table td{border: 1px dashed #d0d0d0;}h88 {color:#fff;font-size:18px;text-align:center;padding:12px 0 16px 0;display:block;background:url(https://s1.ax1x.com/2018/11/21/FCyfNq.png) center bottom no-repeat;}</style> </style> </head> <body style="background-color: #081832;font-family: 'Microsoft Yahei',Tahoma, Arial;"> <h88>百度收录批量查询</h88> <?php if(isset($_POST["tj"])) { $ww1 = $_POST["link_f"]; }else{ $ww1 = "links.txt"; } $ww = $ww1; ?> <?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([email protected]($file)) { $urls[$i] = @fgets($file); $i++; } @fclose($file); $urls = array_filter($urls); foreach($urls as $line) { $arr = checkBaidu($line); if($arr == "1") { $qwer = "<font color='#fff'>→百度已收录</font>"; $y++;$s++; }else { $qwer = "<font color='#7aff00'>→百度未收录</font>"; $w++;$s++; } echo "<table><tbody><tr><td><font color='#fff'>".$line."\t".$qwer."</font></td></tr></tbody></table>"; } echo "<table style='text-align:center;'><tbody><tr><td><font color='#fff'>共有 ".count($urls)." 条,已经查询 ".$s." 条,已收录 ".$y." 条,未收录 ".$w." 条,收录率是".round($y/$s*100,2)."%。</font></td></tr></tbody></table>"; } 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; } } ?> </body> </html>
最新评论