This collection program is a very simple program. I personally think it is not suitable for collecting a large number of data on a single page, because the fopen function is not ideal for remote file operations and multithreading, this is just a combination of the author's experience. the code is as follows... this collection program is a very simple program. I personally think it is not suitable for collecting a large number of data on a single page, the fopen function is not ideal for remote file operations and multithreading. this is just a combination of the codes written by an author who thinks it is fun. the code is as follows:
Utf8_iconv ($ content ):";} /* get all matched content * @ param string $ str content * @ param string $ start match * @ param string $ end abort match * @ return array */private function utf8_iconv ($ content) {return iconv ('gbk', 'utf-8', $ content);} private function strCutAll ($ str, $ start, $ end) {$ content = explode ($ start, $ str); $ matchs = array (); $ sum = count ($ content); for ($ I = 1; $ I <$ sum; $ I ++) {$ tmp = explode ($ end, $ content [$ I ]); $ Matchs [] = $ tmp [0]; unset ($ tmp);} return $ matchs ;} /* obtain the first matched content * @ param string $ str content * @ param string $ start match * @ param string $ end abort match * @ return string */private function strCut ($ str, $ start, $ end) {$ content = strstr ($ str, $ start); $ content = substr ($ content, strlen ($ start), strpos ($ content, $ end)-strlen ($ start); return $ content ;}?>
/* Collection program */header ("content-Type: text/html; charset = utf-8 "); // $ nr = file_get_contents ('/webback/php-yi-ju-hua-hou-men-zhuan '); $ nr = $ this-> fetchbyurl ('/webback/php-yi-ju-hua-hou-men-zhuan'); // recommended, you can also use curl dump ($ this-> strCut ($ nr ,'','
'); // Get the content. You need to further filter (preg_match_all) dump ($ this-> strCutAll ($ nr ,'',''); Get the title