本工具是一款综合性的 LeetCode 数据爬取利器,专门用于爬取 LeetCode 讨论论坛里的面试问题,尤其聚焦于谷歌面试相关问题。它能从讨论中精准提取有价值信息,并按月份进行细致整理,还支持将数据导出为 CSV 或 Google 表格等多种格式,为您的面试准备和数据分析提供极大便利。
本工具能高效爬取 LeetCode 讨论区的面试问题,助您轻松获取所需信息。
git clone https://github.com/yourusername/mcp-leetcode-crawler.git
cd mcp-leetcode-crawler
pip install -r requirements.txt
运行爬虫工具,采用默认设置:
python crawler.py
这将:
leetcode_interview_questions.csv
)。output
目录中的单独 CSV 文件。为了更灵活地控制,使用 CLI:
python cli.py --company google --pages 20 --output results.csv --output-dir monthly_data
可用选项:
--company
:筛选问题的公司标签(默认:google)。--pages
:要爬取的页面数量(默认:10)。--output
:输出 CSV 文件路径(默认:leetcode_interview_questions.csv)。--output-dir
:按月份输出文件的目录(默认:output)。--verbose
:启用详细日志。--category
:爬取的类别(默认:interview-question)。要将数据导出到 Google 表格:
credentials.json
到项目目录中。# 导出单个 CSV 文件
python google_sheets_exporter.py --csv leetcode_interview_questions.csv --name "Google 面试问题"
# 导出所有按月份的数据
python google_sheets_exporter.py --monthly --name "LeetCode 按月面试问题"
使用提供的 shell 脚本:
# 基本运行(仅 CSV)
./run.sh
# 带 Google 表格导出的运行
./run_with_sheets.sh
crawler.py
- 主爬虫实现。cli.py
- 命令行界面。google_sheets_exporter.py
- 导出数据到 Google 表格的工具。run.sh
- 基本执行脚本。run_with_sheets.sh
- 包含 Google 表格导出的执行脚本。requirements.txt
- Python 依赖项。您可以修改脚本来:
请参考项目仓库中的许可证文件。