Questions about PHP Information Retrieval & lt ;? Php & nbsp; $ baiduwww. baidu. coms? Wdsite % 3Ahao123.com; & nbsp; $ sitefile_get_contents ($ baidu); & nbsp; $ site & nbsp; iconv (UTF-8, GB2312 questions about PHP obtaining information
$ Baidu = "http://www.baidu.com/s? Wd = site % 3Ahao123.com ";
$ Site = file_get_contents ($ baidu );
$ Site = iconv ("UTF-8", "GB2312", $ site );
Ereg ("(.*)", $ Site, $ count );
Print_r ($ count); // Obtain the number of topics indexed in Baidu
?>
Result: Array ([0] => [1] => Baidu search _ site: hao123.com)
However:
$ Baidu = "http://www.baidu.com/s? Wd = site % 3Ahao123.com ";
$ Site = file_get_contents ($ baidu );
$ Site = iconv ("UTF-8", "GB2312", $ site );
Ereg ("(.*)", $ Site, $ count );
Print_r ($ count); // Obtain the number of topics indexed in Baidu
?>
This won't work...
Please explain how to get Baidu's indexing ....
------ Best solution --------------------
Preg_match ('%Find the number of related results (.*?) .% I ', $ site, $ count );
------ Other solutions --------------------
The "." in the regular expression matches any character except "\ n" and cannot match Chinese characters.
Preg_match ('%Find the number of related results (.*?) .% I ', $ site, $ count );
Same as the following:
Preg_match ('/Find the number of related results (.*?) ./I ', $ site, $ count );
------ Other solutions --------------------
Reference:
PHP code? 12preg_match ('%
Find the number of related results (.*?) .% I ', $ site, $ count );
In fact
Preg_match ('/Find the number of related results. <\/Strong>/I ', $ site, $ count );
You can.
------ Other solutions --------------------
%Find the number of related results (.*?) .The key to % I is that the last "I" indicates that case sensitivity is ignored. if "I" is not added, "%" is not required.
------ Other solutions --------------------
Reference:
Reference: % is only the start and end character of the regular expression. you can use/, # to start and end the regular expression. it is not ^ $ the first time I heard about it, I was taught ......
What you are talking about is Location Matching. what you are talking about is not one thing.
------ Other solutions --------------------
% Is only the start and end of the regular expression. you can use /, #.
------ Other solutions --------------------
Reference:
% Is only the start and end of the regular expression. you can use /, #.
The start and end of the regular expression are not ^ $ the first time I heard about it, I was taught ......
------ Other solutions --------------------
After learning, I can't quite understand it ..
------ Other solutions --------------------
The above error is reported. "." can match Chinese characters.
------ Other solutions --------------------
This problem mainly applies regular expressions.
------ Other solutions --------------------
Can you tell me why I want to add %?
------ Other solutions --------------------
The reply was deleted by the administrator at 17:27:11, January 19 ,.