diff --git a/src/qimao_epub.py b/src/qimao_epub.py index cebbf08..c63b48a 100644 --- a/src/qimao_epub.py +++ b/src/qimao_epub.py @@ -35,28 +35,29 @@ from tqdm import tqdm import public as p from colorama import Fore, Style, init +import asyncio + +# 设置镜像下载地址 +os.environ["PYPPETEER_DOWNLOAD_HOST"] = "https://mirrors.huaweicloud.com" +from pyppeteer import launch # noqa: E402 init(autoreset=True) # 定义正常模式用来下载7猫小说的函数 -def qimao_epub(url, user_agent, path_choice): - headers = { - "User-Agent": user_agent - } +def qimao_epub(url, path_choice): + + html1, html2 = asyncio.run(get_html(url)) # 创建epub电子书 book = epub.EpubBook() - # 获取网页源码 - response = requests.get(url, headers=headers) - html = response.text - # 解析网页源码 - soup = BeautifulSoup(html, "html.parser") + soup1 = BeautifulSoup(html1, "html.parser") + soup2 = BeautifulSoup(html2, "html.parser") # 获取小说标题 - title = soup.find("h1").get_text() + title = soup1.find('div', {'class': 'title clearfix'}).find('span', {'class': 'txt'}).text # , class_ = "info-name" # 替换非法字符 title = p.rename(title) @@ -65,19 +66,15 @@ def qimao_epub(url, user_agent, path_choice): # info = soup.find("div", class_="page-header-info").get_text() # 获取小说简介 - intro = soup.find("div", class_="page-abstract-content").get_text() + intro = soup1.find('p', class_='intro').get_text().replace(' ', '\n') # 获取小说作者 - author_name = soup.find('span', class_='author-name-text').get_text() - - # 找到type="application/ld+json"的