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?