Copy the code The code is as follows:
//Collect the homepage address
$url="http:/ /emotion.pclady.com.cn/skills/";
//Get the page code
$rs=file_get_contents($url);
//Set matching regular rules
//$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 by your side */
$preg='/
]+">(.*)/i';
//Perform regular search
preg_match_all($preg,$rs,$title);
//Calculate the number of titles
$count=count($ title[0]);
echo $count."
";
//Collect content through the number of titles
for ($i=0;$i<$count;$i++) {
//Set 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 matching regular pattern
$pc='/ ]+">/i';
//Perform regular matching search
preg_match($pc,$c,$content);
//Output 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 of the content page, but why does the regular expression of $pc only match the character < There are none. Is it because I used the subsrt() function above? What else is the problem? Could you please give me some advice?
http://www.bkjia.com/PHPjc/319881.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319881.htmlTechArticleCopy the code as follows: ? //Collect the homepage address $url="http://emotion.pclady.com .cn/skills/"; //Get the page code $rs=file_get_contents($url); //Set matching rules //$fp=fopen("t...