Program PHP information collection program code

Source: Internet
Author: User
Tags preg
Copy CodeThe code is as follows:


Capture Home Address
$url = "http://emotion.pclady.com.cn/skills/";
Get page code
$rs =file_get_contents ($url);
Set matching Regular
$FP =fopen ("Text.txt", "a");
$FW =fwrite ($fp, $rs);
Fclose ($FP);
/*href= "http://emotion.pclady.com.cn/skills/0903/376476.html"
Target=_blank> keep The good man around you
*/
$preg = '/ ]+\ "> (. *) <\/a><\/i>/i ';
Perform a regular search
Preg_match_all ($preg, $rs, $title);
Calculate the number of headings
$count =count ($title [0]);
echo $count. "
";
Content acquisition through the number of headings
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 content page Match regular
$pc = '/]+\ ' >/i ';
Perform a regular match search
Preg_match ($pc, $c, $content);
Output title
echo $title [0][$i]. "
";
echo $title [1][$i]. "
";
$c
echo $concount. "
";
echo $content [0][0];
for ($j =0; $j < $concount; $j + +) {
}
}
?>


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

This character is not the rest of it, because I used the SUBSRT () function? What's the problem? The "

Above introduces the program PHP information collection program code, including the program content, I hope that the PHP tutorial interested friends have helped.

  • 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.