For questions about collecting a number on a page in PHP, please help me write a regular expression. now I want to build a website. I need to obtain the query results of a website remotely. I have some problems with regular expressions, you cannot obtain the expected query result number. Please help me solve the problem: mytool. chinaz. combaidusort. aspx? On hostwww.baidu.com, this is the page for querying the Baidu weight of a domain name. I only need to get the query result and ask the experts to help me write a regular expression about the number of a page collected by PHP.
I want to create a website now, and I need to remotely obtain the query results of a website. I have some issues with the regular expressions I write, and I still cannot obtain the desired query result number. Please help solve the problem:
Http://mytool.chinaz.com/baidusort.aspx? Host = www.baidu.com
The above is the page for querying the Baidu weight of a domain name. I only need to obtain the "Baidu weight is 9" weight number in the query structure,
My code is written as follows:
Function baidu ($ s ){
$ Baidu = "http://mytool.chinaz.com/baidusort.aspx? Host = ". $ s;
$ Site = file_get_contents ($ baidu );
Echo $ site;
Preg_match ('How to write regular expressions here ', $ site, $ count );
Return $ count [0];
}
$ Num1 = baidu ("http://www.baidu.com );
Echo 'website Baidu weight is '. $ num1;
?>
Ask the experts how to write regular expressions and how to obtain the Baidu weight of the query. thank you.
------ Solution --------------------
$ Str = file_get_contents('data.txt ');
$ Nmatches = preg_match ('/
. * (. *) <\/Font>/Uis ', $ str, $ matches );
If ($ nmatches ){
Echo $ matches [1] [0]. PHP_EOL;
}
?>