获取网站百度搜索和搜狗搜索的收录量代码,可以用于获取网站域名在搜索引擎的收录数量,原理是获取搜索引擎site:domain的结果数量,然后再抓取这个数量显示出来,有需要的就拿去吧!
% |) A% B8 L3 f! Q; L6 A
- <?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('域名');?>
- <?php echo sogou('域名');?>
s- E! e( a& h2 b+ U
|