A simple PHP collector-PHP source code

Source: Internet
Author: User
PHP code for a simple PHP collector

 /Is ", $ r, $ booktitle); // match the title of this page $ bookname = $ booktitle [1]; // Obtain the second layer Group $ preg = '/
  • /IsU '; preg_match_all ($ preg, $ r, $ zj); // connect the chapter on this page to $ bookzj = count ($ zj [1]); // calculate the number of chapter titles if ($ ver = "new") {$ content_start =" "; $ Content_end =" ";} If ($ ver =" old ") {$ content_start =" <\/table> "; $ Content_end ="
    ";} Header (" Content-Type: text/html; charset = gb2312 "); writer ($ bookname. "Total ". $ bookzj. "Section \ r \ n handsome Liu Binyu ". date ("d m j G: I: s T Y "). "Design novel collection for graduation \ r \ n ",". /ailaopo /". $ bookname. ". txt "," w + "); for ($ I = 0; $ I <$ bookzj; $ I ++) {// echo" http://book.sina.com.cn ". $ zj [1] [$ I] ". shtml "; die (); // use file_get_contents to connect the chapter to open and read the content of the opened page $ str = file_get_contents (" http://book.sina.com.cn ". $ zj [1] [$ I]. ". shtml "); preg_match ("/()(.*?) (<\/Title>)/is ", $ str, $ title); // match the title of this connection page $ title = str_replace (" _ _ Sina ", "", $ title [2]); // replace _ reading Channel _ xinlang net with null preg_match ("/(". $ content_start. ")(. *?) (". $ Content_end. ")/is", $ str, $ content); // match the content of this connection page $ content = preg_replace ("/<(. *?)> /S "," ", str_replace (" </p> "," \ r \ n ", $ content [2]); // use str_replace to replace </p> In $ content [2] with \ r \ n print_r ($ content); exit ". ($ I + 1 ). "The section, title, and content are connected together with the variable $ result =" \ r \ n ". ($ I + 1 ). "Section --------". $ title. "_ Miss Wang is Shuai --------- \ r \ n ". $ content; writer ($ result ,". /ailaopo /". $ bookname. ". txt "," a + "); // call the function to echo $ result" novel ". $ bookname. "Total ". $ bookzj. "section, now sort it to section ". $ I. "Section _". $ title."
    ";} Echo" novels ". $ bookname." total ". $ bookzj." The section has been fully organized! "; Function writer ($ content, $ url, $ mode) // defines the function name writer parameter $ content, $ url, $ mode {$ fp = fopen ($ url, $ mode); // open the file $ url fwrite ($ fp, $ content); // Put $ content into $ fp fclose ($ fp ); // Close $ fp}?>
  • 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.