PHP获取网站百度搜索和搜狗搜索收录量代码
获取网站百度搜索和搜狗搜索的收录量代码,可以用于获取网站域名在搜索引擎的收录数量,一直想找这个API但没找到,就在网上找了个例子,学习修改了下,可以正常获取百度搜索和搜狗搜索的收录量了;原理是获取搜索引擎site:domain的结果数量,然后再抓取这个数量显示出来,有需要的就拿去吧。
<?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]); } ?> 调用:<?php echo baidu('lanye.org');?> <?php echo sogou('lanye.org');?>
- 版权申明:此文如未标注转载均为本站原创,自由转载请表明出处《蓝叶》。
- 本文网址:https://lanye.org/web/718.html
- 上篇文章:EMLOG自定义文章标题颜色插件
- 下篇文章:用于EMLOG程序的链接ICO图标缓存调用代码