/**
* @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 ');
}
?>
Above describes a night of the woman to set you txt PHP collection book and the implementation of the TXT format code, including a night of the woman to set your TXT content, I hope that the PHP tutorial interested in a friend helpful.