No matter what label is thrown your way, only you can define your self.
不管你被贴上什么标签,只有你才能定义你自己
【活动】:会员128元永久会员早开早划算!
我之前看别人使用QQ机器人的时候,有一个站长工具插件,但是收费,应该是对接的API,本来我想写的,但是写了一半(只写了API部分)发现没什么用,而且百度的经常要验证。我写了百度、bing、搜狗、Google、雅虎这5个的接口。
返回效果如图:

<?php/*Plugin Name: XY-百度收录量Description: XY-根据域名返回百度收录量*/$domain = (isset($_GET['domain']))?$_GET['domain']:$_POST['domain'];if(empty($domain)) echo '查询域名不能为空';$baiducount = baiduSL ($domain);$bingcount = bingSL ($domain);$sogoucount = sogouSL($domain);$googleyahoodata = file_get_contents("http://www.c4r.cn/sl.php?domain=".$domain);$googleyahoojson = json_decode($googleyahoodata);$googlecount = $googleyahoojson -> google;$yahoocount = $googleyahoojson -> yahoo;if(!isset($bingcount)) $bingcount = "查询失败";if(!$bingcount) $bingcount = 0;if(!isset($baiducount)) $baiducount = "查询失败";if(!$baiducount) $baiducount = 0;if(!isset($googlecount)) $googlecount = "查询失败";if(!$googlecount) $googlecount = 0;if(!isset($yahoocount)) $yahoocount = "查询失败";if(!$yahoocount) $yahoocount = 0;$result=array('code'=>1,'domain'=>$domain,'data'=>array('baidu'=>$baiducount,'bing'=>$bingcount,'google'=>$googlecount,'yahoo'=>$yahoocount,'sogou'=>$sogoucount,));print_r(json_encode($result));unset($domain,$result,$ch);function sogouSL ($domain) {$sogou='http://www.sogou.com/web?query=site%3A'.$domain;$sogousite=curl($sogou);$sogousite = str_replace(array("\r\n", "\r", "\n", ' '), '', $sogousite);if (!@$count) preg_match('/<p class="sr-num">找到约(.*?)条结果/i',$sogousite,$count);$sogouSL=@strip_tags($count[1]);unset($count);return $sogouSL;}function baiduSL ($domain) {$baidu='https://www.baidu.com/s?ie=utf-8&tn=baidu&wd=site%3A'.$domain;$bdsite=curl($baidu);$bdsite = str_replace(array("\r\n", "\r", "\n", ' '), '', $bdsite);if (!@$count) preg_match('/找到相关结果数约(.*?)个/i',$bdsite,$count);$baiduSL=@strip_tags($count[1]);unset($count);return $baiduSL;}function bingSL ($domain) {$bing='https://cn.bing.com/search?q=site%3A'.$domain;$bingsite=curl($bing);$bingsite = str_replace(array("\r\n", "\r", "\n", ' '), '', $bingsite);if (!@$count) preg_match('/<span class="sb_count">(.*?) 条结果/i',$bingsite,$count);$bingSL=@strip_tags($count[1]);unset($count);return $bingSL;}function curl($url){$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.49");curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);$ret = curl_exec($ch);curl_close($ch);return $ret;}?><?php /* Plugin Name: XY-百度收录量 Description: XY-根据域名返回百度收录量 */ $domain = (isset($_GET['domain']))?$_GET['domain']:$_POST['domain']; if(empty($domain)) echo '查询域名不能为空'; $baiducount = baiduSL ($domain); $bingcount = bingSL ($domain); $sogoucount = sogouSL($domain); $googleyahoodata = file_get_contents("http://www.c4r.cn/sl.php?domain=".$domain); $googleyahoojson = json_decode($googleyahoodata); $googlecount = $googleyahoojson -> google; $yahoocount = $googleyahoojson -> yahoo; if(!isset($bingcount)) $bingcount = "查询失败"; if(!$bingcount) $bingcount = 0; if(!isset($baiducount)) $baiducount = "查询失败"; if(!$baiducount) $baiducount = 0; if(!isset($googlecount)) $googlecount = "查询失败"; if(!$googlecount) $googlecount = 0; if(!isset($yahoocount)) $yahoocount = "查询失败"; if(!$yahoocount) $yahoocount = 0; $result=array( 'code'=>1, 'domain'=>$domain, 'data'=>array( 'baidu'=>$baiducount, 'bing'=>$bingcount, 'google'=>$googlecount, 'yahoo'=>$yahoocount, 'sogou'=>$sogoucount, ) ); print_r(json_encode($result)); unset($domain,$result,$ch); function sogouSL ($domain) { $sogou='http://www.sogou.com/web?query=site%3A'.$domain; $sogousite=curl($sogou); $sogousite = str_replace(array("\r\n", "\r", "\n", ' '), '', $sogousite); if (!@$count) preg_match('/<p class="sr-num">找到约(.*?)条结果/i',$sogousite,$count); $sogouSL=@strip_tags($count[1]); unset($count); return $sogouSL; } function baiduSL ($domain) { $baidu='https://www.baidu.com/s?ie=utf-8&tn=baidu&wd=site%3A'.$domain; $bdsite=curl($baidu); $bdsite = str_replace(array("\r\n", "\r", "\n", ' '), '', $bdsite); if (!@$count) preg_match('/找到相关结果数约(.*?)个/i',$bdsite,$count); $baiduSL=@strip_tags($count[1]); unset($count); return $baiduSL; } function bingSL ($domain) { $bing='https://cn.bing.com/search?q=site%3A'.$domain; $bingsite=curl($bing); $bingsite = str_replace(array("\r\n", "\r", "\n", ' '), '', $bingsite); if (!@$count) preg_match('/<span class="sb_count">(.*?) 条结果/i',$bingsite,$count); $bingSL=@strip_tags($count[1]); unset($count); return $bingSL; } function curl($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.49"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($ch); curl_close($ch); return $ret; } ?>
Google、雅虎的API代码:
感谢您的来访,获取更多精彩文章请收藏本站。

No matter what label is thrown your way, only you can define your self.
不管你被贴上什么标签,只有你才能定义你自己
© 版权声明
THE END
暂无评论内容