笔趣阁初始化

This commit is contained in:
2026-08-24 11:41:54 +08:00
commit b8ab2f09fc
7 changed files with 66 additions and 0 deletions

23
text.py Normal file
View File

@@ -0,0 +1,23 @@
import os.path
import requests
from lxml import etree
from fake_useragent import UserAgent
class SpiderBiQuGe(object):
def __init__(self):
self.headers = {
"User-Agent":UserAgent().random
}
# 根目录
self.BASE_DIR = os.path.dirname(__file__)
# 源码文件目录,存储爬取到的每一页的源码数据
self.SOURCE_DIR = os.path.join(self.BASE_DIR,"novel","source")
# 文档目录,存储解析到小说的内容
self.NOVEL_DIR = os.path.join(self.BASE_DIR,"novel","novel")
def handler(self,file_name,mode="a",encoding="utf-8",tag="source"):
if tag == "source":
file_path = os.path.join(self.SOURCE_DIR,f"{file_name.html}")