feat: 产品参数爬取系统 v1.0.0

功能:
- 多步骤爬取流程(入口页→列表页→详情页)
- 浏览器爬虫支持(Playwright,处理JS渲染)
- 比亚迪汽车爬虫示例
- 后台管理界面
- 数据存储和导出

技术栈:
- Python 3 + Flask
- Playwright (浏览器自动化)
- BeautifulSoup (HTML解析)

端口:
- API服务: 19011
- 后台管理: 19012
This commit is contained in:
2026-04-10 00:45:51 +08:00
commit 0ee0abbbd1
16 changed files with 1847 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
"""
产品参数爬取系统 - 配置文件
"""
# 服务配置
SERVER_CONFIG = {
"host": "0.0.0.0",
"port": 19011,
"debug": True,
}
ADMIN_CONFIG = {
"host": "0.0.0.0",
"port": 19012,
"debug": True,
}
# 爬虫配置
CRAWLER_CONFIG = {
"timeout": 30,
"retry_times": 3,
"retry_delay": 2,
"concurrent_limit": 3, # 并发限制
"request_delay": 1, # 请求间隔(秒)
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
}
# 数据存储
DATA_DIR = "data"
PRODUCTS_FILE = "products.json"
TASKS_FILE = "tasks.json"
# 浏览器配置
BROWSER_CONFIG = {
"headless": True,
"timeout": 30000,
}
# 爬虫任务配置示例
DEFAULT_SPIDERS = {
"byd": {
"name": "比亚迪汽车",
"enabled": True,
"start_url": "https://www.byd.com/cn/",
"steps": [
{
"name": "获取车型列表",
"type": "browser",
"url": "https://www.byd.com/cn/",
"wait_for": ".car-list",
"parse": {
"type": "css",
"selector": ".car-item a",
"extract": {
"name": "text",
"url": "href"
}
}
},
{
"name": "获取车型详情",
"type": "browser",
"url_from": "previous.url",
"wait_for": ".car-detail",
"parse": {
"type": "css",
"selector": ".param-item",
"extract": {
"param_name": ".name::text",
"param_value": ".value::text"
}
}
}
],
"schedule": "0 2 * * *", # 每天凌晨2点
}
}