PHP Information Acquisition program code _php skills

Source: Internet
Author: User
Copy Code code as follows:

?
Collect 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);
/*<i Class=titles><a
href= "Http://emotion.pclady.com.cn/skills/0903/376476.html"
Target=_blank> keep the good guys around you </a></i>*/
$preg = '/<i\s+class=\ ' titles\ ' ><a\s+href=\ ' [^>]+\ ' > (. *) <\/a><\/i>/i ';
Make a regular search
Preg_match_all ($preg, $rs, $title);
Calculate the number of headers
$count =count ($title [0]);
echo $count. " <br> ";
Content collection through the number of headings
for ($i =0; $i < $count; $i + +) {

Set the content page address
$PR = '/<a\s+href=\ ' [^>]+\ ' >/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 matching regular
$pc = '/<a\s+href=\ ' [^>]+\ ' >/i ';
Make a regular matching search
Preg_match ($pc, $c, $content);
Output title
echo $title [0][$i]. " <br> ";
echo $title [1][$i]. " <br> ";
$concount =count ($content [0]);
echo $concount. " <br> ";
echo $content [0][0];
for ($j =0; $j < $concount; $j + +) {

}
}
?>

By testing, $c is already the data stream of the content page, but why does the regular expression $pc only match < This character is not the other, because I used the SUBSRT () function? What's the problem? Will you please show me your heroes?

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.