Created
December 27, 2019 13:58
-
-
Save nickfox-taterli/4b5287079f6b6bf6cb80ccfe042d6037 to your computer and use it in GitHub Desktop.
小说站单独做某一本书的TXT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
error_reporting(0); | |
function make_books($url) | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$curl_result = curl_exec($ch); | |
curl_close($ch); | |
$output = explode('txttopshow2();', $curl_result)[1]; | |
$output = explode('txttopshow3();', $output)[0]; | |
$output = mb_convert_encoding($output, "UTF-8", "GBK"); | |
$title = \Soundasleep\Html2Text::convert($output); | |
echo $title.PHP_EOL; | |
$content = \Soundasleep\Html2Text::convert($output); | |
$output = explode('txttopshow3();', $curl_result)[1]; | |
$output = explode('txttopshow7();', $output)[0]; | |
$output = mb_convert_encoding($output, "UTF-8", "GBK"); | |
$content = \Soundasleep\Html2Text::convert($output); | |
file_put_contents('XiaoHua.txt', $content, FILE_APPEND); | |
file_put_contents('XiaoHua.txt', PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL, FILE_APPEND); | |
$output = explode('var next_page = "', $curl_result)[1]; | |
$url = explode('";', $output)[0]; | |
if (strcmp('https://www.69shu.com/txt/1464.htm', $url)) { | |
make_books($url); | |
} else { | |
echo '结束'; | |
} | |
} | |
make_books("https://www.69shu.com/txt/1464/6929496"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment