LinkedIn Recruiter 搜索爬虫 & JSON 转 Excel 工具
Project description
search-talent
基于 Selenium 的 LinkedIn Recruiter 搜索爬虫工具,可自动抓取候选人信息并导出为 Excel 文件。
功能特性
- 自动爬取:模拟真人滚动行为,智能加载 LinkedIn Recruiter 搜索结果页的所有候选人信息。
- 结构化数据提取:解析候选人姓名、头衔、地点、工作经历、教育背景、行业、关系度等字段。
- 断点续爬:已保存的页面 JSON 文件会自动跳过,支持中断后继续爬取。
- Excel 导出:一键将 JSON 数据整理并导出为格式化的
.xlsx文件,驼峰命名字段自动拆分,方便阅读。 - CLI 驱动:安装后直接通过终端命令
search-talent运行,无需编写额外脚本。
安装
通过 pip 安装(推荐)
pip install search-talent
从源码安装
git clone https://github.com/your-username/search-talent.git
cd search-talent
pip install .
依赖项
安装时会自动安装以下依赖:
| 依赖 | 用途 |
|---|---|
typer |
CLI 框架 |
selenium |
浏览器自动化 |
beautifulsoup4 |
HTML 解析 |
pandas |
数据处理 |
openpyxl |
Excel 文件读写(pandas 后端) |
browser-dog |
LinkedIn 登录与 Cookie 管理 |
注意:运行爬虫需要本机已安装 Chrome/Chromium 浏览器及对应版本的 ChromeDriver。
前置准备
Cookie 文件
本工具通过 Cookie 注入方式登录 LinkedIn Recruiter,你需要提前准备好一个 cookie.json 文件。
文件内容为 JSON 数组格式,每条记录是一个 Cookie 对象:
[
{
"domain": ".linkedin.com",
"name": "li_at",
"value": "YOUR_COOKIE_VALUE",
"path": "/",
"secure": true,
"httpOnly": true
}
]
提示:可使用浏览器扩展(如 EditThisCookie)导出已登录的 LinkedIn Cookie。
CLI 使用指南
安装完成后,可在终端直接运行 search-talent 命令。
查看帮助
search-talent --help
scrape 命令 - 爬取 LinkedIn 数据
从 LinkedIn Recruiter 搜索结果页爬取候选人信息,并保存为 JSON 文件。
search-talent scrape \
--start-url "https://www.linkedin.com/talent/search?q=..." \
--search-keyword "python-developer" \
--folder ./output
参数说明:
| 参数 | 缩写 | 说明 | 默认值 |
|---|---|---|---|
--start-url |
-s |
LinkedIn Recruiter 搜索结果 URL(必填) | — |
--search-keyword |
-k |
搜索关键词,用于 JSON 文件命名(必填) | — |
--folder |
-f |
保存 JSON 文件的本地目录(必填) | — |
--cookie |
-c |
Cookie JSON 文件路径 | cookie.json |
--scroll-times |
-n |
页面滚动次数 | 3 |
--max-pages |
-m |
最大爬取页数(不指定则不限制) | None |
--headless |
— | 以无头模式运行浏览器 | False |
示例:
# 爬取前 5 页,使用自定义 Cookie 文件
search-talent scrape \
-s "https://www.linkedin.com/talent/search?q=engineer&location=China" \
-k "engineer-china" \
-f ./data/engineer-china \
-c ~/linkedin_cookie.json \
-m 5
# 无头模式运行
search-talent scrape \
-s "https://www.linkedin.com/talent/search?q=..." \
-k "my-search" \
-f ./data \
--headless
export 命令 - 导出为 Excel
将 scrape 命令生成的 JSON 文件合并导出为一份 Excel 文件。
search-talent export \
--input ./output \
--output candidates.xlsx
参数说明:
| 参数 | 缩写 | 说明 | 默认值 |
|---|---|---|---|
--input |
-i |
包含 JSON 文件的输入目录(必填) | — |
--output |
-o |
输出 Excel 文件路径(必填) | — |
示例:
search-talent export -i ./data/engineer-china -o engineer-china.xlsx
项目结构
search-talent/
├── pyproject.toml # 项目配置与构建定义
├── README.md
└── src/
└── search_talent/
├── __init__.py # 包入口,版本信息
├── scraper.py # LinkedIn 爬虫核心模块
├── reader.py # JSON 读取与 Excel 导出模块
└── cli.py # Typer CLI 入口
注意事项
- 合规使用:请遵守 LinkedIn 的使用条款,合理控制爬取频率和数量,避免账号被封禁。
- Cookie 有效期:LinkedIn Cookie 会过期,若登录失败请重新导出 Cookie 文件。
- 反爬机制:工具内置了随机等待、拟人滚动等反检测策略,但仍建议控制爬取速度。
- ChromeDriver 版本:请确保本机 ChromeDriver 版本与 Chrome 浏览器版本匹配。
许可证
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file search_talent-0.1.0.tar.gz.
File metadata
- Download URL: search_talent-0.1.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e04dfd6c6e9ea5e188a6616c80826f808b14db1931fdb2a692e705334ed86d3
|
|
| MD5 |
5f562626d208fc53401da14f67c857f6
|
|
| BLAKE2b-256 |
ccb36514967f1957d710a066b35bf31f4b4acd150fe248bace2b08796e31dd0d
|
File details
Details for the file search_talent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: search_talent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd0222941b64482f535a7b140a7f874317d4dfdde219f5ee22d285f4581d8ce
|
|
| MD5 |
3136bf36183ea4d370bcaced1848e3a6
|
|
| BLAKE2b-256 |
3b1ca61dff615bb7132baf8344af8a1ac875d0bc8bfbf18b7ffbc75723fd899c
|