小说下载器

import requests
from lxml import etree
import time

url="https://www.85xscc.com/book/doupocangqiong/13495.html"
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"}

while 1:
try:
resp=requests.get(url,headers=headers)
except:
print("未知异常")
time.sleep(1)
continue
resp.encoding="utf-8"

e=etree.HTML(resp.text)
info="\n".join(e.xpath('//div[@class="m-post"]/p/text()'))
title=e.xpath('//h1/text()')[0]

with open("斗破苍穹.txt", "a", encoding='utf-8') as f:
f.write(title+"\n\n"+info+"\n\n")

url=f"https://www.85xs.cc{e.xpath('//tr/td[2]/a/@href')[0]}"
time.sleep(1)
print(title)

 

posted @   jzm1/  阅读(129)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示