<?php
$baidu="http://www.baidu.com/s?wd=site%3Ahao123.com";
$site=file_get_contents($baidu);
$site= iconv("UTF-8","GB2312", $site);
ereg("<title>(.*)</title>", $site,$count);
print_r($count); //获取好主题在百度中的收录数量?>
这个能获得结果:Array ( [0] => [1] => 百度搜索_site:hao123.com )
但是:<?php
$baidu="http://www.baidu.com/s?wd=site%3Ahao123.com";
$site=file_get_contents($baidu);
$site= iconv("UTF-8","GB2312", $site);
ereg("<strong>(.*)</strong>", $site,$count);
print_r($count); //获取好主题在百度中的收录数量?>
这个就不行了
求解释,还有怎么获得百度收录量。
$baidu="http://www.baidu.com/s?wd=site%3Ahao123.com";
$site=file_get_contents($baidu);
$site= iconv("UTF-8","GB2312", $site);
ereg("<title>(.*)</title>", $site,$count);
print_r($count); //获取好主题在百度中的收录数量?>
这个能获得结果:Array ( [0] => [1] => 百度搜索_site:hao123.com )
但是:<?php
$baidu="http://www.baidu.com/s?wd=site%3Ahao123.com";
$site=file_get_contents($baidu);
$site= iconv("UTF-8","GB2312", $site);
ereg("<strong>(.*)</strong>", $site,$count);
print_r($count); //获取好主题在百度中的收录数量?>
这个就不行了
求解释,还有怎么获得百度收录量。
preg_match('%<strong>找到相关结果数(.*?)个。</strong>%i', $site,$count);
正则里面的"."匹配除"\n"外的任意一个字符,不能匹配中文。
preg_match('%<strong>找到相关结果数(.*?)个。</strong>%i', $site,$count);
和下面的一样:
preg_match('/<strong>找到相关结果数(.*?)个。</strong>/i', $site,$count);
preg_match('/<strong>找到相关结果数(.*)个。<\/strong>/i',$site,$count);
就可以了。