猫史档案馆


【Python作品分享】小说txt下载

用户:川奈.U4vO川奈.U4vO查看:0 回复:1 评论:0 创建时间:2020-10-11T17:15:04


【作品展示】

center_image

 

【作品介绍】

下载电子书

 

【作品源代码】

from urllib.request import urlopen

myurl = 'https://www.zwdu.com/book/31855/'
myhost = myurl[0:myurl.find("/", 10)]
f = open('d:/text.txt', 'w+', encoding='gbk')
喵sg = urlopen(myurl).read().decode('gbk')
tmsg = 喵sg.find("
  
") while tmsg > 0: t = 喵sg[tmsg:喵sg.find("
", tmsg)] 喵sg = 喵sg[喵sg.find("", tmsg):] tmsg = 喵sg.find("
") chapurl = myhost + t[t.find("\"") + 1: t.find("\"", t.find("\"") + 2)] chapname = t[t.find("\">")+2:t.find("", t.find("\">")+6)]+"\n" temp = urlopen(chapurl).read().decode('gbk') content = temp[temp.find("")+18:temp.find( "", temp.find("")+20)] + "\n" content = content.replace("\t", "") content = content.replace("
", "\n") f.write(chapname) f.write(content) f.close()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
小鹿deer小鹿deer

加油

点赞0


评论