Php information collection code _ PHP Tutorial

Source: Internet
Author: User
Tags preg
Php information collection program code. Copy the code as follows :? Collection homepage address $ urlemotion.pclady.com. cnskills; get page code $ rsfile_get_contents ($ url); set matching regular expression $ fpfopen (t The code is as follows:


// Collection homepage address
$ Url = "http://emotion.pclady.com.cn/skills ";
// Obtain the page code
$ Rs = file_get_contents ($ url );
// Set the matching regular expression
// $ Fp = fopen ("text.txt", "");
// $ Fw = fwrite ($ fp, $ rs );
// Fclose ($ fp );
/*Href = "http://emotion.pclady.com.cn/skills/0903/376476.html"
Target = _ blank> keep the good guys around you
*/
$ Preg = '/ ] + \ "> (. *) <\/A> <\/I>/I ';
// Perform regular search
Preg_match_all ($ preg, $ rs, $ title );
// Calculate the number of titles
$ Count = count ($ title [0]);
Echo $ count ."
";
// Collect content by the number of titles
For ($ I = 0; $ I <$ count; $ I ++ ){

// Set the content page address
$ Pr = '/] + \ ">/isu ';
Preg_match_all ($ pr, $ title [0] [$ I], $ jurl );
$ Substr = substr ($ jurl [0] [0], 9 );
$ Curl = substr ($ substr, 0,-18 );
// Get the content page code
$ C = file_get_contents ($ curl );
// Set the content page to match the regular expression
$ Pc = '/] + \ ">/I ';
// Perform regular match search
Preg_match ($ pc, $ c, $ content );
// Output the title
Echo $ title [0] [$ I]."
";
Echo $ title [1] [$ I]."
";
$ Concount = count ($ content [0]);
Echo $ concount ."
";
Echo $ content [0] [0];
For ($ j = 0; $ j <$ concount; $ j ++ ){

}
}
?>


After detection, $ c is already the data stream on the content page, but why does the regular expression $ pc only match? <这个字符其他的都没有呢,是因为我上面用了subsrt()函数吗?还是什么问题?麻烦各位大侠指点迷津啊?< p>

The http://www.bkjia.com/PHPjc/319881.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319881.htmlTechArticle code is as follows :? // Collect the home address $ url = "http://emotion.pclady.com.cn/skills/"; // get the page code $ rs = file_get_contents ($ url ); // Set the matching regular expression // $ fp = fopen ("t...

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.