For questions about how PHP collects a number on a page, please help me write a regular expression.

Source: Internet
Author: User
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 solve the master: http://mytool.chinaz.com/baidusort.aspx? Host = ww ask the experts to help write a regular expression about a number on 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;
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.