linkedin-api 1.1.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- linkedin_api-2.0.0/LICENSE +21 -0
- linkedin_api-2.0.0/PKG-INFO +236 -0
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/README.md +97 -49
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/linkedin_api/__init__.py +1 -1
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/linkedin_api/client.py +74 -27
- linkedin_api-2.0.0/linkedin_api/cookie_repository.py +68 -0
- linkedin_api-2.0.0/linkedin_api/linkedin.py +1455 -0
- linkedin_api-2.0.0/linkedin_api/settings.py +7 -0
- linkedin_api-2.0.0/linkedin_api/utils/helpers.py +259 -0
- linkedin_api-2.0.0/linkedin_api.egg-info/PKG-INFO +236 -0
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/linkedin_api.egg-info/SOURCES.txt +2 -0
- linkedin_api-2.0.0/linkedin_api.egg-info/requires.txt +3 -0
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/setup.py +3 -3
- linkedin_api-1.1.0/PKG-INFO +0 -185
- linkedin_api-1.1.0/linkedin_api/linkedin.py +0 -618
- linkedin_api-1.1.0/linkedin_api/settings.py +0 -4
- linkedin_api-1.1.0/linkedin_api/utils/helpers.py +0 -7
- linkedin_api-1.1.0/linkedin_api.egg-info/PKG-INFO +0 -185
- linkedin_api-1.1.0/linkedin_api.egg-info/requires.txt +0 -1
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/linkedin_api/utils/__init__.py +0 -0
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/linkedin_api.egg-info/dependency_links.txt +0 -0
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/linkedin_api.egg-info/top_level.txt +0 -0
- {linkedin_api-1.1.0 → linkedin_api-2.0.0}/setup.cfg +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Tom Quirk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: linkedin_api
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Python wrapper for the Linkedin API
|
|
5
|
+
Home-page: https://github.com/tomquirk/linkedin-api
|
|
6
|
+
Author: Tom Quirk
|
|
7
|
+
Author-email: tomquirkacc@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
|
|
16
|
+
# Linkedin API for Python
|
|
17
|
+
|
|
18
|
+
<h3 align="center">Sponsors</h3>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://lix-it.com/pages/linkedin-api?utm_campaign=influencer%20marketing&utm_source=github&utm_medium=social&utm_content=tomquirk" target="_blank">
|
|
22
|
+
<img height="45px" style="margin-right:15px" src="./assets/logos/lix.png" alt="Lix">
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://nubela.co/proxycurl/?utm_campaign=influencer%20marketing&utm_source=github&utm_medium=social&utm_term=-&utm_content=tom%20quirk" target="_blank">
|
|
25
|
+
<img height="45px" src="./assets/logos/proxycurl.png" alt="proxycurl">
|
|
26
|
+
</a>
|
|
27
|
+
<a href="https://iscraper.io/" target="_blank">
|
|
28
|
+
<img height="45px" src="./assets/logos/iscraper.png" alt="serpsbot">
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://www.piloterr.com/?ref=tomquirk" target="_blank">
|
|
31
|
+
<img height="45px" src="./assets/logos/piloterr.png" alt="piloterr">
|
|
32
|
+
</a>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
<h5 align="center"><a href="https://github.com/sponsors/tomquirk/sponsorships?sponsor=tomquirk&tier_id=96653&preview=false" target="_blank">Become a sponsor</a></h5>
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
Programmatically send messages, get jobs, and search profiles with a regular Linkedin user account.
|
|
40
|
+
|
|
41
|
+
No "official" API access required - just use a valid Linkedin account!
|
|
42
|
+
|
|
43
|
+
**Caution**: This library is not officially supported by LinkedIn. Using it might violate LinkedIn's Terms of Service. Use it at your own risk.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
> Python >= 3.6 required
|
|
48
|
+
|
|
49
|
+
To install the linkedin_api package, use the following command:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip3 install git+https://github.com/tomquirk/linkedin-api.git
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Quick Start
|
|
56
|
+
|
|
57
|
+
> See all methods on the [documentation website](https://linkedin-api.readthedocs.io/).
|
|
58
|
+
|
|
59
|
+
Below is a basic example of how to use linkedin_api:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from linkedin_api import Linkedin
|
|
63
|
+
|
|
64
|
+
# Authenticate using any Linkedin account credentials
|
|
65
|
+
api = Linkedin('reedhoffman@linkedin.com', '*******')
|
|
66
|
+
|
|
67
|
+
# GET a profile
|
|
68
|
+
profile = api.get_profile('billy-g')
|
|
69
|
+
|
|
70
|
+
# GET a profiles contact info
|
|
71
|
+
contact_info = api.get_profile_contact_info('billy-g')
|
|
72
|
+
|
|
73
|
+
# GET 1st degree connections of a given profile
|
|
74
|
+
connections = api.get_profile_connections('1234asc12304')
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Commercial Alternative
|
|
78
|
+
|
|
79
|
+
> This is a sponsored section
|
|
80
|
+
|
|
81
|
+
Scrape public LinkedIn profile data at scale with [Proxycurl APIs](https://nubela.co/proxycurl/?utm_campaign=influencer%20marketing&utm_source=github&utm_medium=social&utm_term=-&utm_content=tom%20quirk).
|
|
82
|
+
|
|
83
|
+
- Scraping Public profiles are battle tested in court in HiQ VS LinkedIn case.
|
|
84
|
+
- GDPR, CCPA, SOC2 compliant
|
|
85
|
+
- High rate limit - 300 requests/minute
|
|
86
|
+
- Fast - APIs respond in ~2s
|
|
87
|
+
- Fresh data - 88% of data is scraped real-time, other 12% are not older than 29 days
|
|
88
|
+
- High accuracy
|
|
89
|
+
- Tons of data points returned per profile
|
|
90
|
+
|
|
91
|
+
Built for developers, by developers.
|
|
92
|
+
|
|
93
|
+
> End sponsored section
|
|
94
|
+
|
|
95
|
+
## Documentation
|
|
96
|
+
|
|
97
|
+
For comprehensive documentation, including available methods and parameters, visit the [documentation](https://linkedin-api.readthedocs.io/).
|
|
98
|
+
|
|
99
|
+
[Learn more](#how-it-works) about how it works.
|
|
100
|
+
|
|
101
|
+
## Disclaimer
|
|
102
|
+
|
|
103
|
+
This library is not endorsed or supported by LinkedIn. It is an unofficial library intended for educational purposes and personal use only. By using this library, you agree to not hold the author or contributors responsible for any consequences resulting from its usage.
|
|
104
|
+
|
|
105
|
+
## Contributing
|
|
106
|
+
|
|
107
|
+
We welcome contributions! [Learn how to find endpoints](#to-find-endpoints)
|
|
108
|
+
|
|
109
|
+
## Development Setup
|
|
110
|
+
|
|
111
|
+
### Dependencies
|
|
112
|
+
|
|
113
|
+
- Python 3.7
|
|
114
|
+
- A valid Linkedin user account (don't use your personal account, if possible)
|
|
115
|
+
- `pipenv` (optional)
|
|
116
|
+
|
|
117
|
+
### Development installation
|
|
118
|
+
|
|
119
|
+
1. Create a `.env` config file. An example is provided in `.env.example` - you include at least all of the settings set there.
|
|
120
|
+
2. Using pipenv...
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
pipenv install --dev
|
|
124
|
+
pipenv shell
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Running tests
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python -m pytest tests
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Troubleshooting
|
|
134
|
+
|
|
135
|
+
#### I keep getting a `CHALLENGE`
|
|
136
|
+
|
|
137
|
+
Linkedin will throw you a curve ball in the form of a Challenge URL. We currently don't handle this, and so you're kinda screwed. We think it could be only IP-based (i.e. logging in from different location). Your best chance at resolution is to log out and log back in on your browser.
|
|
138
|
+
|
|
139
|
+
**Known reasons for Challenge** include:
|
|
140
|
+
|
|
141
|
+
- 2FA
|
|
142
|
+
- Rate-limit - "It looks like you’re visiting a very high number of pages on LinkedIn.". Note - n=1 experiment where this page was hit after ~900 contiguous requests in a single session (within the hour) (these included random delays between each request), as well as a bunch of testing, so who knows the actual limit.
|
|
143
|
+
|
|
144
|
+
Please add more as you come across them.
|
|
145
|
+
|
|
146
|
+
#### Search problems
|
|
147
|
+
|
|
148
|
+
- Mileage may vary when searching general keywords like "software" using the standard `search` method. They've recently added some smarts around search whereby they group results by people, company, jobs etc. if the query is general enough. Try to use an entity-specific search method (i.e. search_people) where possible.
|
|
149
|
+
|
|
150
|
+
## How it works
|
|
151
|
+
|
|
152
|
+
> Before using this project, please consult the [Terms and Conditions](#terms-and-conditions) and [Legal Notice](#legal).
|
|
153
|
+
|
|
154
|
+
This project attempts to provide a simple Python interface for the Linkedin API.
|
|
155
|
+
|
|
156
|
+
> Do you mean the [legit Linkedin API](https://developer.linkedin.com/)?
|
|
157
|
+
|
|
158
|
+
NO! To retrieve structured data, the [Linkedin Website](https://linkedin.com) uses a service they call **Voyager**. Voyager endpoints give us access to pretty much everything we could want from Linkedin: profiles, companies, connections, messages, etc. - anything that you can see on linkedin.com, we can get from Voyager.
|
|
159
|
+
|
|
160
|
+
This project aims to provide complete coverage for Voyager.
|
|
161
|
+
|
|
162
|
+
[How does it work?](#in-depth-overview)
|
|
163
|
+
|
|
164
|
+
### In-depth overview
|
|
165
|
+
|
|
166
|
+
Voyager endpoints look like this:
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
https://www.linkedin.com/voyager/api/identity/profileView/tom-quirk
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Or, more clearly
|
|
173
|
+
|
|
174
|
+
```text
|
|
175
|
+
___________________________________ _______________________________
|
|
176
|
+
| base path | resource |
|
|
177
|
+
https://www.linkedin.com/voyager/api /identity/profileView/tom-quirk
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
They are authenticated with a simple cookie, which we send with every request, along with a bunch of headers.
|
|
181
|
+
|
|
182
|
+
To get a cookie, we POST a given username and password (of a valid Linkedin user account) to `https://www.linkedin.com/uas/authenticate`.
|
|
183
|
+
|
|
184
|
+
### To find endpoints
|
|
185
|
+
|
|
186
|
+
We're looking at the Linkedin website and we spot some data we want. What now?
|
|
187
|
+
|
|
188
|
+
The most reliable method to find the relevant endpoint is to:
|
|
189
|
+
|
|
190
|
+
1. `view source`
|
|
191
|
+
2. `command-f`/search the page for some keyword in the data. This will exist inside of a `<code>` tag.
|
|
192
|
+
3. Scroll down to the **next adjacent element** which will be another `<code>` tag, probably with an `id` that looks something like
|
|
193
|
+
|
|
194
|
+
```html
|
|
195
|
+
<code style="display: none" id="datalet-bpr-guid-3900675">
|
|
196
|
+
{"request":"/voyager/api/identity/profiles/tom-quirk/profileView","status":200,"body":"bpr-guid-3900675"}
|
|
197
|
+
</code>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
4. The value of `request` is the url! 🤘
|
|
201
|
+
|
|
202
|
+
You can also use the `network` tab in you browsers developer tools, but you will encounter mixed results.
|
|
203
|
+
|
|
204
|
+
### How Clients query Voyager
|
|
205
|
+
|
|
206
|
+
linkedin.com queries data using the [Rest-li Protocol](https://linkedin.github.io/rest.li/spec/protocol). Rest-li is an internal query language/syntax where clients (like linkedin.com) to specify what data they want (similar to the GraphQL concept).
|
|
207
|
+
|
|
208
|
+
Here's an example of making a request for an organisation's `name` and `groups` (the Linkedin groups it manages):
|
|
209
|
+
|
|
210
|
+
```text
|
|
211
|
+
/voyager/api/organization/companies?decoration=(name,groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url))&q=universalName&universalName=linkedin
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The "querying" happens in the `decoration` parameter, which looks like
|
|
215
|
+
|
|
216
|
+
```text
|
|
217
|
+
(
|
|
218
|
+
name,
|
|
219
|
+
groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url)
|
|
220
|
+
)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
So here, we request an organisation name, and a list of groups, where for each group we want `largeLogo`, `groupName`, etc.
|
|
224
|
+
|
|
225
|
+
Different endpoints use different parameters (and perhaps even different syntaxes) to specify these queries. Notice that the above query had a parameter `q` whose value was `universalName`; the query was then specified with the `decoration` parameter.
|
|
226
|
+
|
|
227
|
+
In contrast, the `/search/cluster` endpoint uses `q=guided`, and specifies its query with the `guided` parameter, whose value is something like
|
|
228
|
+
|
|
229
|
+
```text
|
|
230
|
+
List(v->PEOPLE)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
It could be possible to document (and implement a nice interface for) this query language - as we add more endpoints to this project, I'm sure it will become more clear if such a thing would be possible (and if it's worth it).
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
@@ -1,46 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Linkedin API for Python
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<h3 align="center">Sponsors</h3>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://lix-it.com/pages/linkedin-api?utm_campaign=influencer%20marketing&utm_source=github&utm_medium=social&utm_content=tomquirk" target="_blank">
|
|
7
|
+
<img height="45px" style="margin-right:15px" src="./assets/logos/lix.png" alt="Lix">
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://nubela.co/proxycurl/?utm_campaign=influencer%20marketing&utm_source=github&utm_medium=social&utm_term=-&utm_content=tom%20quirk" target="_blank">
|
|
10
|
+
<img height="45px" src="./assets/logos/proxycurl.png" alt="proxycurl">
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://iscraper.io/" target="_blank">
|
|
13
|
+
<img height="45px" src="./assets/logos/iscraper.png" alt="serpsbot">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://www.piloterr.com/?ref=tomquirk" target="_blank">
|
|
16
|
+
<img height="45px" src="./assets/logos/piloterr.png" alt="piloterr">
|
|
17
|
+
</a>
|
|
18
|
+
</p>
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
<h5 align="center"><a href="https://github.com/sponsors/tomquirk/sponsorships?sponsor=tomquirk&tier_id=96653&preview=false" target="_blank">Become a sponsor</a></h5>
|
|
8
21
|
|
|
9
|
-
|
|
22
|
+
---
|
|
10
23
|
|
|
11
|
-
|
|
24
|
+
Programmatically send messages, get jobs, and search profiles with a regular Linkedin user account.
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
No "official" API access required - just use a valid Linkedin account!
|
|
14
27
|
|
|
15
|
-
|
|
28
|
+
**Caution**: This library is not officially supported by LinkedIn. Using it might violate LinkedIn's Terms of Service. Use it at your own risk.
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> Do you mean the [legit Linkedin API](https://developer.linkedin.com/)?
|
|
20
|
-
|
|
21
|
-
NO! To retrieve structured data, the [Linkedin Website](https://linkedin.com) uses a service they call **Voyager**. Voyager endpoints give us access to pretty much everything we could want from Linkedin: profiles, companies, connections, messages, etc. - anything that you can see on linkedin.com, we can get from Voyager.
|
|
22
|
-
|
|
23
|
-
So specifically, this project aims to provide complete coverage for Voyager.
|
|
30
|
+
## Installation
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
> Python >= 3.6 required
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
To install the linkedin_api package, use the following command:
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
```bash
|
|
37
|
+
pip3 install git+https://github.com/tomquirk/linkedin-api.git
|
|
38
|
+
```
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
### Quick Start
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
$ pip install linkedin-api
|
|
35
|
-
```
|
|
42
|
+
> See all methods on the [documentation website](https://linkedin-api.readthedocs.io/).
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
Below is a basic example of how to use linkedin_api:
|
|
38
45
|
|
|
39
46
|
```python
|
|
40
47
|
from linkedin_api import Linkedin
|
|
41
48
|
|
|
42
49
|
# Authenticate using any Linkedin account credentials
|
|
43
|
-
api = Linkedin('reedhoffman@linkedin.com', '
|
|
50
|
+
api = Linkedin('reedhoffman@linkedin.com', '*******')
|
|
44
51
|
|
|
45
52
|
# GET a profile
|
|
46
53
|
profile = api.get_profile('billy-g')
|
|
@@ -48,13 +55,41 @@ profile = api.get_profile('billy-g')
|
|
|
48
55
|
# GET a profiles contact info
|
|
49
56
|
contact_info = api.get_profile_contact_info('billy-g')
|
|
50
57
|
|
|
51
|
-
# GET
|
|
52
|
-
connections = api.get_profile_connections('1234asc12304'
|
|
58
|
+
# GET 1st degree connections of a given profile
|
|
59
|
+
connections = api.get_profile_connections('1234asc12304')
|
|
53
60
|
```
|
|
54
61
|
|
|
62
|
+
## Commercial Alternative
|
|
63
|
+
|
|
64
|
+
> This is a sponsored section
|
|
65
|
+
|
|
66
|
+
Scrape public LinkedIn profile data at scale with [Proxycurl APIs](https://nubela.co/proxycurl/?utm_campaign=influencer%20marketing&utm_source=github&utm_medium=social&utm_term=-&utm_content=tom%20quirk).
|
|
67
|
+
|
|
68
|
+
- Scraping Public profiles are battle tested in court in HiQ VS LinkedIn case.
|
|
69
|
+
- GDPR, CCPA, SOC2 compliant
|
|
70
|
+
- High rate limit - 300 requests/minute
|
|
71
|
+
- Fast - APIs respond in ~2s
|
|
72
|
+
- Fresh data - 88% of data is scraped real-time, other 12% are not older than 29 days
|
|
73
|
+
- High accuracy
|
|
74
|
+
- Tons of data points returned per profile
|
|
75
|
+
|
|
76
|
+
Built for developers, by developers.
|
|
77
|
+
|
|
78
|
+
> End sponsored section
|
|
79
|
+
|
|
55
80
|
## Documentation
|
|
56
81
|
|
|
57
|
-
For
|
|
82
|
+
For comprehensive documentation, including available methods and parameters, visit the [documentation](https://linkedin-api.readthedocs.io/).
|
|
83
|
+
|
|
84
|
+
[Learn more](#how-it-works) about how it works.
|
|
85
|
+
|
|
86
|
+
## Disclaimer
|
|
87
|
+
|
|
88
|
+
This library is not endorsed or supported by LinkedIn. It is an unofficial library intended for educational purposes and personal use only. By using this library, you agree to not hold the author or contributors responsible for any consequences resulting from its usage.
|
|
89
|
+
|
|
90
|
+
## Contributing
|
|
91
|
+
|
|
92
|
+
We welcome contributions! [Learn how to find endpoints](#to-find-endpoints)
|
|
58
93
|
|
|
59
94
|
## Development Setup
|
|
60
95
|
|
|
@@ -62,54 +97,66 @@ For a complete reference documentation, see the [DOCS.md](https://github.com/tom
|
|
|
62
97
|
|
|
63
98
|
- Python 3.7
|
|
64
99
|
- A valid Linkedin user account (don't use your personal account, if possible)
|
|
65
|
-
-
|
|
100
|
+
- `pipenv` (optional)
|
|
66
101
|
|
|
67
|
-
###
|
|
102
|
+
### Development installation
|
|
68
103
|
|
|
69
104
|
1. Create a `.env` config file. An example is provided in `.env.example` - you include at least all of the settings set there.
|
|
70
105
|
2. Using pipenv...
|
|
71
106
|
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
|
|
107
|
+
```bash
|
|
108
|
+
pipenv install --dev
|
|
109
|
+
pipenv shell
|
|
75
110
|
```
|
|
76
111
|
|
|
77
112
|
### Running tests
|
|
78
113
|
|
|
79
|
-
```
|
|
80
|
-
|
|
114
|
+
```bash
|
|
115
|
+
python -m pytest tests
|
|
81
116
|
```
|
|
82
117
|
|
|
83
118
|
### Troubleshooting
|
|
84
119
|
|
|
85
|
-
####
|
|
120
|
+
#### I keep getting a `CHALLENGE`
|
|
86
121
|
|
|
87
122
|
Linkedin will throw you a curve ball in the form of a Challenge URL. We currently don't handle this, and so you're kinda screwed. We think it could be only IP-based (i.e. logging in from different location). Your best chance at resolution is to log out and log back in on your browser.
|
|
88
123
|
|
|
89
|
-
|
|
124
|
+
**Known reasons for Challenge** include:
|
|
90
125
|
|
|
91
126
|
- 2FA
|
|
92
127
|
- Rate-limit - "It looks like you’re visiting a very high number of pages on LinkedIn.". Note - n=1 experiment where this page was hit after ~900 contiguous requests in a single session (within the hour) (these included random delays between each request), as well as a bunch of testing, so who knows the actual limit.
|
|
93
128
|
|
|
94
129
|
Please add more as you come across them.
|
|
95
130
|
|
|
96
|
-
#### Search
|
|
131
|
+
#### Search problems
|
|
97
132
|
|
|
98
133
|
- Mileage may vary when searching general keywords like "software" using the standard `search` method. They've recently added some smarts around search whereby they group results by people, company, jobs etc. if the query is general enough. Try to use an entity-specific search method (i.e. search_people) where possible.
|
|
99
134
|
|
|
100
|
-
|
|
135
|
+
## How it works
|
|
136
|
+
|
|
137
|
+
> Before using this project, please consult the [Terms and Conditions](#terms-and-conditions) and [Legal Notice](#legal).
|
|
138
|
+
|
|
139
|
+
This project attempts to provide a simple Python interface for the Linkedin API.
|
|
140
|
+
|
|
141
|
+
> Do you mean the [legit Linkedin API](https://developer.linkedin.com/)?
|
|
142
|
+
|
|
143
|
+
NO! To retrieve structured data, the [Linkedin Website](https://linkedin.com) uses a service they call **Voyager**. Voyager endpoints give us access to pretty much everything we could want from Linkedin: profiles, companies, connections, messages, etc. - anything that you can see on linkedin.com, we can get from Voyager.
|
|
144
|
+
|
|
145
|
+
This project aims to provide complete coverage for Voyager.
|
|
101
146
|
|
|
102
|
-
|
|
147
|
+
[How does it work?](#in-depth-overview)
|
|
148
|
+
|
|
149
|
+
### In-depth overview
|
|
103
150
|
|
|
104
151
|
Voyager endpoints look like this:
|
|
105
152
|
|
|
106
|
-
```
|
|
153
|
+
```text
|
|
107
154
|
https://www.linkedin.com/voyager/api/identity/profileView/tom-quirk
|
|
108
155
|
```
|
|
109
156
|
|
|
110
157
|
Or, more clearly
|
|
111
158
|
|
|
112
|
-
```
|
|
159
|
+
```text
|
|
113
160
|
___________________________________ _______________________________
|
|
114
161
|
| base path | resource |
|
|
115
162
|
https://www.linkedin.com/voyager/api /identity/profileView/tom-quirk
|
|
@@ -119,9 +166,7 @@ They are authenticated with a simple cookie, which we send with every request, a
|
|
|
119
166
|
|
|
120
167
|
To get a cookie, we POST a given username and password (of a valid Linkedin user account) to `https://www.linkedin.com/uas/authenticate`.
|
|
121
168
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
### To find endpoints...
|
|
169
|
+
### To find endpoints
|
|
125
170
|
|
|
126
171
|
We're looking at the Linkedin website and we spot some data we want. What now?
|
|
127
172
|
|
|
@@ -130,28 +175,30 @@ The most reliable method to find the relevant endpoint is to:
|
|
|
130
175
|
1. `view source`
|
|
131
176
|
2. `command-f`/search the page for some keyword in the data. This will exist inside of a `<code>` tag.
|
|
132
177
|
3. Scroll down to the **next adjacent element** which will be another `<code>` tag, probably with an `id` that looks something like
|
|
178
|
+
|
|
133
179
|
```html
|
|
134
180
|
<code style="display: none" id="datalet-bpr-guid-3900675">
|
|
135
181
|
{"request":"/voyager/api/identity/profiles/tom-quirk/profileView","status":200,"body":"bpr-guid-3900675"}
|
|
136
182
|
</code>
|
|
137
183
|
```
|
|
138
|
-
|
|
184
|
+
|
|
185
|
+
4. The value of `request` is the url! 🤘
|
|
139
186
|
|
|
140
187
|
You can also use the `network` tab in you browsers developer tools, but you will encounter mixed results.
|
|
141
188
|
|
|
142
189
|
### How Clients query Voyager
|
|
143
190
|
|
|
144
|
-
|
|
191
|
+
linkedin.com queries data using the [Rest-li Protocol](https://linkedin.github.io/rest.li/spec/protocol). Rest-li is an internal query language/syntax where clients (like linkedin.com) to specify what data they want (similar to the GraphQL concept).
|
|
145
192
|
|
|
146
193
|
Here's an example of making a request for an organisation's `name` and `groups` (the Linkedin groups it manages):
|
|
147
194
|
|
|
148
|
-
```
|
|
195
|
+
```text
|
|
149
196
|
/voyager/api/organization/companies?decoration=(name,groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url))&q=universalName&universalName=linkedin
|
|
150
197
|
```
|
|
151
198
|
|
|
152
199
|
The "querying" happens in the `decoration` parameter, which looks like
|
|
153
200
|
|
|
154
|
-
```
|
|
201
|
+
```text
|
|
155
202
|
(
|
|
156
203
|
name,
|
|
157
204
|
groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url)
|
|
@@ -164,8 +211,9 @@ Different endpoints use different parameters (and perhaps even different syntaxe
|
|
|
164
211
|
|
|
165
212
|
In contrast, the `/search/cluster` endpoint uses `q=guided`, and specifies its query with the `guided` parameter, whose value is something like
|
|
166
213
|
|
|
167
|
-
```
|
|
214
|
+
```text
|
|
168
215
|
List(v->PEOPLE)
|
|
169
216
|
```
|
|
170
217
|
|
|
171
218
|
It could be possible to document (and implement a nice interface for) this query language - as we add more endpoints to this project, I'm sure it will become more clear if such a thing would be possible (and if it's worth it).
|
|
219
|
+
|