[Python] 纯文本查看 复制代码#Author:c0ld
import os
import re
import urllib.request
from bs4 import BeautifulSoup
#定义核心函数
def getlink(url):
file = urllib.request.urlopen(url)
data = str(file.read())
#构造正则表达式来匹配章节链接
link = re.compile(pat).findall(data)
opener = urllib.request.build_opener()
urllib.request.install_opener(opener)
data = urllib.request.urlopen(link).read()
soup = BeautifulSoup(data, 'html.parser')
value = soup.find('div', id="content")
book = title.get_text()+value.get_text()
print(title.get_text()+" 下载完成...")
bookid = input("请输入书籍编号(www.qu.la/book/书籍编号/):")
url = "https://www.qu.la/book/"+bookid
print('================================================')
links = "https://www.qu.la"+linklist[0:]
filewrite = open('links.txt','a+')
filewrite = open('links.txt','a+')
print('================================================')
filewrite = open('Book.txt','a+')
print('================================================')
print('小说下载完成!请在本目录查找Book.txt')