PHP 获取网站百度搜索和搜狗搜索收录量代码
获取网站百度搜索和搜狗搜索的收录量代码,可以用于获取网站域名在搜索引擎的收录数量,一直想找这个API但没找到,就在网上找了个例子,学习修改了下,可以正常获取百度搜索和搜狗搜索的收录量了;原理是获取搜索引擎site:domain的结果数量,然后再抓取这个数量显示出来。
<meta charset="utf-8"> <?php function baidu($url){ $baidu="http://www.baidu.com/s?wd=site:".$url; $site=file_get_contents($baidu); ereg("该网站共有(.*)个网页被百度收录", $site,$count); $count=str_replace("该网站共有","",$count); $count=str_replace("个网页被百度收录","",$count); $count=str_replace(",","",$count); $count=str_replace(" ","",$count); return strip_tags($count[0]); } function sogou($url){ $sogou="http://www.sogou.com/web?query=site:".$url; $site=file_get_contents($sogou); ereg("找到约 (.*) 条结果", $site,$count); $count=str_replace("找到约","",$count); $count=str_replace("条结果","",$count); $count=str_replace(",","",$count); $count=str_replace(" ","",$count); return strip_tags($count[0]); } ?> www.iteye.com 百度收录<?php echo baidu('www.iteye.com');?>条<br> www.iteye.com 搜狗收录<?php echo sogou('www.iteye.com');?>条
效果图:
相关推荐
fadacai0 2016-04-18
AIOps智能运维 2010-08-17
rojyang 2020-05-20
ELEMENTS爱乐小超 2020-05-07
baynkbtg 2019-11-02
ksjlhy 2019-10-28
geminihr 2015-03-19
chang00 2015-06-17
LinSeeker 2019-09-07
nextwhy 2012-09-09
tongjianru 2011-05-18
Jarvan 2016-09-25
deusrwvf 2017-06-21
AIOps智能运维 2015-05-25
magvwiz 2013-10-18
linqiang 2010-02-04
XSxing 2019-06-30