l4rm4nd/LinkedInDumper
GitHub: l4rm4nd/LinkedInDumper
一款基于 LinkedIn 非官方 API 的员工数据抓取工具,解决批量获取社交平台人员信息的问题。
Stars: 580 | Forks: 56
## 💬 描述
LinkedInDumper 是一个 Python 3 脚本,用于从 LinkedIn 社交平台抓取员工数据。
结果包含名字、姓氏、职位、地点以及用户个人资料链接。如果公司员工不超过 10 人,仅需 2 次 API 调用即可获取所有员工信息。否则,必须对 API 结果进行分页处理。使用 `--email-format` CLI 参数,可以定义 Python 字符串格式来根据获取到的名字和姓氏自动生成电子邮件地址。
## ✨ 要求
LinkedInDumper 通过非官方的 LinkedIn Voyager API 进行通信,这需要身份验证。因此,你必须拥有一个有效的 LinkedIn 用户账户。为了简化操作,LinkedInDumper 只需要你提供一个 Cookie 值。以这种方式操作,即使启用了 2FA 的账户也支持。此外,你需要提供一个 LinkedIn 公司 URL 以便抓取员工信息。
#### 获取 LinkedIn Cookie
1. 登录 www.linkedin.com 并获取你的 ``li_at`` 会话 Cookie 值(例如通过开发者工具)
2. 在 Python 脚本的变量 ``li_at`` 中持久化指定该 Cookie 值,或在运行时通过 CLI 参数 ``--cookie`` 临时指定
#### 获取 LinkedIn 公司 URL
1. 在 Google 搜索或直接在 LinkedIn 中搜索目标公司
2. LinkedIn 公司 URL 应类似于以下格式:https://www.linkedin.com/company/apple
## 🎓 使用方法
```
usage: linkedindumper.py [-h] --url [--cookie ] [--quiet] [--include-private-profiles] [--include-contact-infos] [--jitter] [--email-format ] [--output-json ] [--output-csv ]
options:
-h, --help show this help message and exit
--url A LinkedIn company url - https://www.linkedin.com/company/
--cookie LinkedIn 'li_at' session cookie
--include-private-profiles
Show private accounts too
--include-contact-infos
Query each employee individually and retrieve contact infos
--jitter Add a random jitter to HTTP requests to bypass rate limiting
--email-format
Python string format for emails; for example:
--email-format '{0}.{1}@example.com' --> john.doe@example.com
--email-format '{0[0]}.{1}@example.com' --> j.doe@example.com
--email-format '{1}@example.com' --> doe@example.com
--email-format '{0}@example.com' --> john@example.com
--email-format '{0[0]}{1[0]}@example.com' --> jd@example.com
--output-json
Store results in json output file
--output-csv
Store results in csv output file
```
### 🐳 示例 1 - Docker 运行
```
docker run --rm l4rm4nd/linkedindumper:latest --url 'https://www.linkedin.com/company/apple' --cookie '' --email-format '{0}.{1}@apple.de'
```
### 🐍 示例 2 - 原生 Python
```
# 安装依赖
pip install -r requirements.txt
python3 linkedindumper.py --url 'https://www.linkedin.com/company/apple' --cookie '' --email-format '{0}.{1}@apple.de'
```
## 💎 输出结果
脚本将以分号分隔的值(类似 CSV)返回员工数据:
```
██▓ ██▓ ███▄ █ ██ ▄█▀▓█████ ▓█████▄ ██▓ ███▄ █ ▓█████▄ █ ██ ███▄ ▄███▓ ██▓███ ▓█████ ██▀███
▓██▒ ▓██▒ ██ ▀█ █ ██▄█▒ ▓█ ▀ ▒██▀ ██▌▓██▒ ██ ▀█ █ ▒██▀ ██▌ ██ ▓██▒▓██▒▀█▀ ██▒▓██░ ██▒▓█ ▀ ▓██ ▒ ██▒
▒██░ ▒██▒▓██ ▀█ ██▒▓███▄░ ▒███ ░██ █▌▒██▒▓██ ▀█ ██▒░██ █▌▓██ ▒██░▓██ ▓██░▓██░ ██▓▒▒███ ▓██ ░▄█ ▒
▒██░ ░██░▓██▒ ▐▌██▒▓██ █▄ ▒▓█ ▄ ░▓█▄ ▌░██░▓██▒ ▐▌██▒░▓█▄ ▌▓▓█ ░██░▒██ ▒██ ▒██▄█▓▒ ▒▒▓█ ▄ ▒██▀▀█▄
░██████▒░██░▒██░ ▓██░▒██▒ █▄░▒████▒░▒████▓ ░██░▒██░ ▓██░░▒████▓ ▒▒█████▓ ▒██▒ ░██▒▒██▒ ░ ░░▒████▒░██▓ ▒██▒
░ ▒░▓ ░░▓ ░ ▒░ ▒ ▒ ▒ ▒▒ ▓▒░░ ▒░ ░ ▒▒▓ ▒ ░▓ ░ ▒░ ▒ ▒ ▒▒▓ ▒ ░▒▓▒ ▒ ▒ ░ ▒░ ░ ░▒▓▒░ ░ ░░░ ▒░ ░░ ▒▓ ░▒▓░
░ ░ ▒ ░ ▒ ░░ ░░ ░ ▒░░ ░▒ ▒░ ░ ░ ░ ░ ▒ ▒ ▒ ░░ ░░ ░ ▒░ ░ ▒ ▒ ░░▒░ ░ ░ ░ ░ ░░▒ ░ ░ ░ ░ ░▒ ░ ▒░
░ ░ ▒ ░ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░░ ░ ░ ░ ░ ░░ ░ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ by LRVT
[i] Company Name: apple
[i] Company X-ID: 162479
[i] LN Employees: 1000 employees found
[i] Dumping Date: 17/10/2022 13:55:06
[i] Email Format: {0}.{1}@apple.de
Firstname;Lastname;Email;Position;Gender;Location;Profile
Katrin;Honauer;katrin.honauer@apple.de;Software Engineer at Apple;N/A;Heidelberg;https://www.linkedin.com/in/katrin-honauer
Raymond;Chen;raymond.chen@apple.de;Recruiting at Apple;N/A;Austin, Texas Metropolitan Area;https://www.linkedin.com/in/raytherecruiter
[i] Successfully crawled 2 unique apple employee(s). Hurray ^_-
```
可选地,你可以使用 CLI 参数 `--output-json` 和 `--output-csv` 将结果存储为 JSON 或 CSV 格式。
## 💥 限制
LinkedIn 在采集联系信息时最多只允许返回前 1000 条搜索结果。当你达到免费版 LinkedIn 账户允许的最大查询次数访问个人资料时,可能需要 LinkedIn 高级账户。
此外,并非所有员工个人资料都是公开的。结果会根据你所使用的 LinkedIn 账户以及你是否与该公司的某些员工建立了好友关系而有所不同。因此,有时无法获取某些员工账户的名字、姓氏和个人资料 URL。对于这类个人资料,脚本不会显示它们,因为它们包含默认值,例如名字为 "LinkedIn",姓氏为 "Member"。如果你希望包含这些私有个人资料,请使用 CLI 参数 ``--include-private-profiles``。尽管某些账户可能是私有的,我们仍然可以获取职位(头衔)和位置信息。只有名字、姓氏和个人资料 URL 对于私有 LinkedIn 账户被隐藏。
最后,LinkedIn 用户可以自由命名他们的个人资料。因此,账户名称可能包含各种内容,如称呼、缩写、表情符号、中间名等。我已尽力移除一些无意义内容,但这并非通用问题的完整解决方案。请注意,我们并未使用官方 LinkedIn API。该脚本从“未官方”的 Voyager API 收集信息。
你可以使用实验性的 `--include-contact-infos` CLI 参数来检索用户的附加联系信息(名字、姓氏、地址、电话、电子邮件等)。这将为每个枚举的 LinkedIn 用户账户单独查询并使用 GraphQL API 获取数据。它仅返回 JSON 格式输出,且请求量较大。是否返回数据取决于用户的隐私设置和你用于枚举的 LinkedIn 账户。
如果你看到类似 `maximum request exceeded` 的错误信息,请尝试使用 `--jitter` CLI 参数引入一些延迟以自动执行 API 请求。这可能有助于绕过 LinkedIn 实现的检测或速率限制。
## 🤖 仓库统计

标签:API, DNS解析, LinkedIn, Python3, URL抓取, 人员检索, 人肉搜索, 公司员工, 员工信息, 安全测试, 开源项目, 招聘分析, 攻击性安全, 数据导出, 数据抓取, 社交工程, 网络调试, 职业社交, 自动化, 请求拦截
