PHP acquisition book and synthesis of TXT format implementation Code _php tutorial

Source: Internet
Author: User
/**
* @name collection book. php
* @date Sun Mar 22:48:02 CST 2009
* @copyright Ma Yongjin (Myz)
* @author Ma Yongjin (Myz)
* @link http://blog.csdn.net/mayongzhan/
*/
Header (' Content-type:text/html;charset=utf8 ');
Header (' content-type:text/html;charset=gb2312 ');
Error_reporting (E_all);
Date_default_timezone_set (' Asia/shanghai ');
Set_time_limit (0);
function writer ($content, $url)
{
$fp = fopen ($url, ' ab ');
Fwrite ($fp, $content);
Fclose ($FP);
}
$folder = ' 2 '; Folder
$book _base_url = ' xxxxxxxxxxxxxxxxxxxxx ';
$book _url = ' yyyyyyyyyyyyy.html ';
$main = file_get_contents ($book _base_url. $book _url);
Preg_match_all ('/chapter_.*?\.html/', $main, $pages);
$pages = Array_unique ($pages [0]);
foreach ($pages as $value) {
Writer (file_get_contents ($book _base_url $value), './'. $folder. ' /'. $value. '. TXT ');
$str = file_get_contents ('./'. $folder. ' /'. $value. '. TXT ');
Print_r ($STR);
Preg_match ("/(

)(.*?) (<\/h1>) (.*?) ()(.*?) (<\/div>)/S ", $str, $arr);
Print_r ($arr);d ie ();
$arr [6] = Preg_replace ("/( ]+>.*?] +>) (. *?) (<\/a><\/span>)/S "," $ ", preg_replace ("/

|<\/p>/"," \ r \ n ", $arr [6]);
$result = "\ r \ n------------------------------------------------\r\ n------------------------------------------------\ r \------------------------------------------------\r\ N----------------". $arr [2]." \ r \ n------------------------------------------------\ r \------------------------------------------------\r\ n------------------------------------------------\ r \ nyou '. $arr [6];
Writer ($result, './'. $folder. ' /new.txt ');
}
?>

http://www.bkjia.com/PHPjc/319775.html www.bkjia.com true http://www.bkjia.com/PHPjc/319775.html techarticle PHP/** * @name collection book. php * @date Sun Mar 22:48:02 CST Ma Yongjin * @copyright (MYZ) * @author Ma Yongjin (myz) * @link/HTTP/ blog.csdn.net/mayongzhan/*///header (' Conten ...

  • Related Article

    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.