docs/原生环境管理文档.md
uv --version 验证。>= 16.0.0。# 进入项目根目录
cd MediaCrawler
# 使用 uv 保证 Python 版本和依赖一致性
uv sync
uv run playwright install
项目已支持使用 Playwright 连接本地 Chrome。如需使用 CDP 方式,可在
config/base_config.py中调整xhs和dy的相关配置。
# 项目默认未开启评论爬取,如需评论请在 config/base_config.py 中修改 ENABLE_GET_COMMENTS
# 其他功能开关也可在 config/base_config.py 查看,均有中文注释
# 从配置中读取关键词搜索并爬取帖子与评论
uv run main.py --platform xhs --lt qrcode --type search
# 从配置中读取指定帖子ID列表并爬取帖子与评论
uv run main.py --platform xhs --lt qrcode --type detail
# 其他平台示例
uv run main.py --help
如果爬取抖音或知乎,需要提前安装 Node.js,版本
>= 16。
# 进入项目根目录
cd MediaCrawler
# 创建虚拟环境(示例 Python 版本:3.11,requirements 基于该版本)
python -m venv venv
# macOS & Linux 激活虚拟环境
source venv/bin/activate
# Windows 激活虚拟环境
venv\Scripts\activate
pip install -r requirements.txt
playwright install
# 从配置中读取关键词搜索并爬取帖子与评论
python main.py --platform xhs --lt qrcode --type search
# 从配置中读取指定帖子ID列表并爬取帖子与评论
python main.py --platform xhs --lt qrcode --type detail
# 更多示例
python main.py --help