Home  >  Article  >  Backend Development  >  PHP information collection program code_PHP tutorial

PHP information collection program code_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:47:491082browse

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?

www.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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn