吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 275|回复: 5
收起左侧

[资源求助] 求将这本小说下载成txt版本的

[复制链接]
273045208 发表于 2025-5-8 14:29
25吾爱币
https://www.shulalala.com/book_185727/

最佳答案

查看完整内容

不知道全不全你先拿去看着-------https://pan.quark.cn/s/c9ca5c0c6ed5 提取码:fZVt

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

zicoolbk 发表于 2025-5-8 14:29
不知道全不全你先拿去看着-------https://pan.quark.cn/s/c9ca5c0c6ed5
提取码:fZVt
 楼主| 273045208 发表于 2025-5-8 14:36
[Asm] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import requests
from bs4 import BeautifulSoup
import time
 
# 基础配置
base_url = "https://www.shulalua.com/book_185727/"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit...'}
 
# 获取目录页
def get_chapters():
    response = requests.get(base_url, headers=headers)
    soup = BeautifulSoup(response.text, 'html.parser')
    # 根据实际页面结构调整选择器
    return [a['href'] for a in soup.select('.chapter-list a')]
 
# 章节内容抓取
def get_content(chapter_url):
    try:
        res = requests.get(chapter_url, headers=headers)
        res.encoding = 'utf-8'  # 根据网页实际编码调整
        soup = BeautifulSoup(res.text, 'html.parser')
        # 提取正文(需审查元素确认选择器)
        content = soup.find('div', class_='content').text.strip() 
        return content.replace('\n\n', '\n')
    except Exception as e:
        print(f'抓取失败:{chapter_url} - {str(e)}')
        return ''
 
# 主程序
if __name__ == '__main__':
    chapters = get_chapters()
    with open('novel.txt', 'w', encoding='utf-8') as f:
        for idx, url in enumerate(chapters, 1):
            content = get_content(url)
            f.write(f'第{idx}章\n{content}\n\n')
            print(f'已完成第{idx}章')
            time.sleep(1)  # 降低请求频率
 楼主| 273045208 发表于 2025-5-8 17:37
zicoolbk 发表于 2025-5-8 14:29
不知道全不全你先拿去看着-------https://pan.quark.cn/s/c9ca5c0c6ed5
提取码:fZVt

差50多章,够用了,谢谢
zicoolbk 发表于 2025-5-8 18:29
273045208 发表于 2025-5-8 17:37
差50多章,够用了,谢谢

可能我搜的还是不够太新
jiwuhui 发表于 2025-5-8 20:05
开源阅读下的  不是楼主指定的来源  不保障质量

通过网盘分享的文件:求生:从小木屋开始抵御寒流 作者:山寻.txt
链接: https://pan.baidu.com/s/1jzD2QGTQpK_d9K8Ldj33Ig?pwd=74df 提取码: 74df
--来自百度网盘超级会员v9的分享

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
273045208 + 1 + 1 谢谢@Thanks!

查看全部评分

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-30 04:12

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表