linkedin-api 2.2.1__tar.gz → 2.3.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.2.1 → linkedin_api-2.3.0}/PKG-INFO +55 -40
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/README.md +54 -39
- linkedin_api-2.3.0/linkedin_api/__init__.py +7 -0
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/linkedin_api/linkedin.py +161 -9
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/pyproject.toml +1 -7
- linkedin_api-2.2.1/linkedin_api/__init__.py +0 -17
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/LICENSE +0 -0
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/linkedin_api/client.py +0 -0
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/linkedin_api/cookie_repository.py +0 -0
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/linkedin_api/settings.py +0 -0
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/linkedin_api/utils/__init__.py +0 -0
- {linkedin_api-2.2.1 → linkedin_api-2.3.0}/linkedin_api/utils/helpers.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: linkedin-api
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: LinkedIn API for Python
|
|
5
5
|
Home-page: https://github.com/tomquirk/linkedin-api
|
|
6
6
|
License: MIT
|
|
@@ -22,12 +22,11 @@ Project-URL: Documentation, https://linkedin-api.readthedocs.io
|
|
|
22
22
|
Project-URL: Repository, https://github.com/tomquirk/linkedin-api
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
<div align="center">
|
|
27
26
|
|
|
28
27
|
# LinkedIn API for Python
|
|
29
|
-
 [](https://pypi.org/project/linkedin-api/) [](#license) [](https://linkedin-api.readthedocs.io) [](https://pypi.org/project/linkedin-api/)
|
|
30
28
|
|
|
29
|
+
 [](https://linkedin-api.readthedocs.io) [](https://pypi.org/project/linkedin-api/) [](https://discord.gg/9w5c6xzm)
|
|
31
30
|
|
|
32
31
|
Search profiles, send messages, find jobs and more in Python. No official API access required.
|
|
33
32
|
|
|
@@ -47,22 +46,22 @@ Search profiles, send messages, find jobs and more in Python. No official API ac
|
|
|
47
46
|
|
|
48
47
|
<p align="center" dir="auto" >
|
|
49
48
|
<a href="https://bit.ly/3AFPGZd" target="_blank">
|
|
50
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
49
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/proapis.png" alt="iScraper by ProAPIs">
|
|
51
50
|
</a>
|
|
52
51
|
<a href="https://bit.ly/3SWnB63" target="_blank">
|
|
53
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
52
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/prospeo.png" alt="Prospeo">
|
|
54
53
|
</a>
|
|
55
54
|
<a href="https://bit.ly/3SRximo" target="_blank">
|
|
56
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
55
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/proxycurl.png" alt="proxycurl">
|
|
57
56
|
</a>
|
|
58
57
|
<a href="https://bit.ly/3Mbksvd" target="_blank">
|
|
59
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
58
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/lix.png" alt="Lix">
|
|
60
59
|
</a>
|
|
61
60
|
<a href="https://bit.ly/3WOIMrX" target="_blank">
|
|
62
|
-
<img height="70px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
61
|
+
<img height="70px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/unipile.png" alt="Unipile">
|
|
63
62
|
</a>
|
|
64
63
|
<a href="https://bit.ly/4fUyE9J" target="_blank">
|
|
65
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
64
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/scrapin.png" alt="Scrapin">
|
|
66
65
|
</a>
|
|
67
66
|
</p>
|
|
68
67
|
|
|
@@ -81,15 +80,15 @@ Search profiles, send messages, find jobs and more in Python. No official API ac
|
|
|
81
80
|
|
|
82
81
|
And more! [Read the docs](https://linkedin-api.readthedocs.io/en/latest/api.html) for all API methods.
|
|
83
82
|
|
|
84
|
-
## Installation
|
|
85
|
-
|
|
86
83
|
> [!IMPORTANT]
|
|
87
|
-
> This library is not officially supported by LinkedIn. Using this might violate LinkedIn's Terms of Service. Use it at your own risk.
|
|
84
|
+
> This library is not officially supported by LinkedIn. Using this library might violate LinkedIn's Terms of Service. Use it at your own risk.
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
88
87
|
|
|
89
88
|
> [!NOTE]
|
|
90
|
-
> Python >= 3.
|
|
89
|
+
> Python >= 3.10 required
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
###
|
|
93
92
|
|
|
94
93
|
```bash
|
|
95
94
|
pip install linkedin-api
|
|
@@ -104,14 +103,14 @@ pip install git+https://github.com/tomquirk/linkedin-api.git
|
|
|
104
103
|
### Quick Start
|
|
105
104
|
|
|
106
105
|
> [!TIP]
|
|
107
|
-
> See all methods on the [
|
|
106
|
+
> See all API methods on the [docs](https://linkedin-api.readthedocs.io/en/latest/api.html).
|
|
108
107
|
|
|
109
108
|
The following snippet demonstrates a few basic linkedin_api use cases:
|
|
110
109
|
|
|
111
110
|
```python
|
|
112
111
|
from linkedin_api import Linkedin
|
|
113
112
|
|
|
114
|
-
# Authenticate using any Linkedin account credentials
|
|
113
|
+
# Authenticate using any Linkedin user account credentials
|
|
115
114
|
api = Linkedin('reedhoffman@linkedin.com', '*******')
|
|
116
115
|
|
|
117
116
|
# GET a profile
|
|
@@ -124,12 +123,6 @@ contact_info = api.get_profile_contact_info('billy-g')
|
|
|
124
123
|
connections = api.get_profile_connections('1234asc12304')
|
|
125
124
|
```
|
|
126
125
|
|
|
127
|
-
## Documentation
|
|
128
|
-
|
|
129
|
-
For comprehensive documentation, including available methods and parameters, visit the [documentation](https://linkedin-api.readthedocs.io/).
|
|
130
|
-
|
|
131
|
-
[Learn more](#how-it-works) about how it works.
|
|
132
|
-
|
|
133
126
|
## Commercial alternatives
|
|
134
127
|
|
|
135
128
|
> This is a sponsored section
|
|
@@ -248,36 +241,53 @@ Get started [here](https://bit.ly/3AFPGZd).
|
|
|
248
241
|
|
|
249
242
|
> End sponsored section
|
|
250
243
|
|
|
251
|
-
## Disclaimer
|
|
252
|
-
|
|
253
|
-
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.
|
|
254
|
-
|
|
255
|
-
## Contributing
|
|
256
|
-
|
|
257
|
-
We welcome contributions! [Learn how to find endpoints](#find-new-endpoints).
|
|
258
|
-
|
|
259
244
|
## Development
|
|
260
245
|
|
|
261
246
|
### Dependencies
|
|
262
247
|
|
|
263
|
-
-
|
|
248
|
+
- [`poetry`](https://python-poetry.org/docs/)
|
|
264
249
|
- A valid Linkedin user account (don't use your personal account, if possible)
|
|
265
|
-
- [`pipenv`](https://pipenv.pypa.io/en/latest/) (optional)
|
|
266
250
|
|
|
267
251
|
### Development installation
|
|
268
252
|
|
|
269
|
-
1. Create a `.env` config file
|
|
270
|
-
2. Install dependencies
|
|
253
|
+
1. Create a `.env` config file (use `.env.example` as a reference)
|
|
254
|
+
2. Install dependencies using `poetry`:
|
|
271
255
|
|
|
272
256
|
```bash
|
|
273
|
-
|
|
274
|
-
|
|
257
|
+
poetry install
|
|
258
|
+
poetry self add poetry-plugin-dotenv
|
|
275
259
|
```
|
|
276
260
|
|
|
277
261
|
### Run tests
|
|
278
262
|
|
|
263
|
+
Run all tests:
|
|
264
|
+
|
|
279
265
|
```bash
|
|
280
|
-
|
|
266
|
+
poetry run pytest
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Run unit tests:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
poetry run pytest tests/unit
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Run E2E tests:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
poetry run pytest tests/e2e
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Lint
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
poetry run black --check .
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Or to fix:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
poetry run black .
|
|
281
291
|
```
|
|
282
292
|
|
|
283
293
|
### Troubleshooting
|
|
@@ -382,7 +392,12 @@ It could be possible to document (and implement a nice interface for) this query
|
|
|
382
392
|
|
|
383
393
|
### Release a new version
|
|
384
394
|
|
|
385
|
-
1. Bump `
|
|
386
|
-
1. `
|
|
387
|
-
1. `
|
|
395
|
+
1. Bump `version` in `pyproject.toml`
|
|
396
|
+
1. `poetry build`
|
|
397
|
+
1. `poetry publish`
|
|
398
|
+
1. Draft release notes in GitHub.
|
|
399
|
+
|
|
400
|
+
## Disclaimer
|
|
401
|
+
|
|
402
|
+
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.
|
|
388
403
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
1
|
<div align="center">
|
|
3
2
|
|
|
4
3
|
# LinkedIn API for Python
|
|
5
|
-
 [](https://pypi.org/project/linkedin-api/) [](#license) [](https://linkedin-api.readthedocs.io) [](https://pypi.org/project/linkedin-api/)
|
|
6
4
|
|
|
5
|
+
 [](https://linkedin-api.readthedocs.io) [](https://pypi.org/project/linkedin-api/) [](https://discord.gg/9w5c6xzm)
|
|
7
6
|
|
|
8
7
|
Search profiles, send messages, find jobs and more in Python. No official API access required.
|
|
9
8
|
|
|
@@ -23,22 +22,22 @@ Search profiles, send messages, find jobs and more in Python. No official API ac
|
|
|
23
22
|
|
|
24
23
|
<p align="center" dir="auto" >
|
|
25
24
|
<a href="https://bit.ly/3AFPGZd" target="_blank">
|
|
26
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
25
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/proapis.png" alt="iScraper by ProAPIs">
|
|
27
26
|
</a>
|
|
28
27
|
<a href="https://bit.ly/3SWnB63" target="_blank">
|
|
29
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
28
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/prospeo.png" alt="Prospeo">
|
|
30
29
|
</a>
|
|
31
30
|
<a href="https://bit.ly/3SRximo" target="_blank">
|
|
32
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
31
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/proxycurl.png" alt="proxycurl">
|
|
33
32
|
</a>
|
|
34
33
|
<a href="https://bit.ly/3Mbksvd" target="_blank">
|
|
35
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
34
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/lix.png" alt="Lix">
|
|
36
35
|
</a>
|
|
37
36
|
<a href="https://bit.ly/3WOIMrX" target="_blank">
|
|
38
|
-
<img height="70px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
37
|
+
<img height="70px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/unipile.png" alt="Unipile">
|
|
39
38
|
</a>
|
|
40
39
|
<a href="https://bit.ly/4fUyE9J" target="_blank">
|
|
41
|
-
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/
|
|
40
|
+
<img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/main/docs/assets/logos/scrapin.png" alt="Scrapin">
|
|
42
41
|
</a>
|
|
43
42
|
</p>
|
|
44
43
|
|
|
@@ -57,15 +56,15 @@ Search profiles, send messages, find jobs and more in Python. No official API ac
|
|
|
57
56
|
|
|
58
57
|
And more! [Read the docs](https://linkedin-api.readthedocs.io/en/latest/api.html) for all API methods.
|
|
59
58
|
|
|
60
|
-
## Installation
|
|
61
|
-
|
|
62
59
|
> [!IMPORTANT]
|
|
63
|
-
> This library is not officially supported by LinkedIn. Using this might violate LinkedIn's Terms of Service. Use it at your own risk.
|
|
60
|
+
> This library is not officially supported by LinkedIn. Using this library might violate LinkedIn's Terms of Service. Use it at your own risk.
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
64
63
|
|
|
65
64
|
> [!NOTE]
|
|
66
|
-
> Python >= 3.
|
|
65
|
+
> Python >= 3.10 required
|
|
67
66
|
|
|
68
|
-
|
|
67
|
+
###
|
|
69
68
|
|
|
70
69
|
```bash
|
|
71
70
|
pip install linkedin-api
|
|
@@ -80,14 +79,14 @@ pip install git+https://github.com/tomquirk/linkedin-api.git
|
|
|
80
79
|
### Quick Start
|
|
81
80
|
|
|
82
81
|
> [!TIP]
|
|
83
|
-
> See all methods on the [
|
|
82
|
+
> See all API methods on the [docs](https://linkedin-api.readthedocs.io/en/latest/api.html).
|
|
84
83
|
|
|
85
84
|
The following snippet demonstrates a few basic linkedin_api use cases:
|
|
86
85
|
|
|
87
86
|
```python
|
|
88
87
|
from linkedin_api import Linkedin
|
|
89
88
|
|
|
90
|
-
# Authenticate using any Linkedin account credentials
|
|
89
|
+
# Authenticate using any Linkedin user account credentials
|
|
91
90
|
api = Linkedin('reedhoffman@linkedin.com', '*******')
|
|
92
91
|
|
|
93
92
|
# GET a profile
|
|
@@ -100,12 +99,6 @@ contact_info = api.get_profile_contact_info('billy-g')
|
|
|
100
99
|
connections = api.get_profile_connections('1234asc12304')
|
|
101
100
|
```
|
|
102
101
|
|
|
103
|
-
## Documentation
|
|
104
|
-
|
|
105
|
-
For comprehensive documentation, including available methods and parameters, visit the [documentation](https://linkedin-api.readthedocs.io/).
|
|
106
|
-
|
|
107
|
-
[Learn more](#how-it-works) about how it works.
|
|
108
|
-
|
|
109
102
|
## Commercial alternatives
|
|
110
103
|
|
|
111
104
|
> This is a sponsored section
|
|
@@ -224,36 +217,53 @@ Get started [here](https://bit.ly/3AFPGZd).
|
|
|
224
217
|
|
|
225
218
|
> End sponsored section
|
|
226
219
|
|
|
227
|
-
## Disclaimer
|
|
228
|
-
|
|
229
|
-
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.
|
|
230
|
-
|
|
231
|
-
## Contributing
|
|
232
|
-
|
|
233
|
-
We welcome contributions! [Learn how to find endpoints](#find-new-endpoints).
|
|
234
|
-
|
|
235
220
|
## Development
|
|
236
221
|
|
|
237
222
|
### Dependencies
|
|
238
223
|
|
|
239
|
-
-
|
|
224
|
+
- [`poetry`](https://python-poetry.org/docs/)
|
|
240
225
|
- A valid Linkedin user account (don't use your personal account, if possible)
|
|
241
|
-
- [`pipenv`](https://pipenv.pypa.io/en/latest/) (optional)
|
|
242
226
|
|
|
243
227
|
### Development installation
|
|
244
228
|
|
|
245
|
-
1. Create a `.env` config file
|
|
246
|
-
2. Install dependencies
|
|
229
|
+
1. Create a `.env` config file (use `.env.example` as a reference)
|
|
230
|
+
2. Install dependencies using `poetry`:
|
|
247
231
|
|
|
248
232
|
```bash
|
|
249
|
-
|
|
250
|
-
|
|
233
|
+
poetry install
|
|
234
|
+
poetry self add poetry-plugin-dotenv
|
|
251
235
|
```
|
|
252
236
|
|
|
253
237
|
### Run tests
|
|
254
238
|
|
|
239
|
+
Run all tests:
|
|
240
|
+
|
|
255
241
|
```bash
|
|
256
|
-
|
|
242
|
+
poetry run pytest
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Run unit tests:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
poetry run pytest tests/unit
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Run E2E tests:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
poetry run pytest tests/e2e
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Lint
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
poetry run black --check .
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Or to fix:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
poetry run black .
|
|
257
267
|
```
|
|
258
268
|
|
|
259
269
|
### Troubleshooting
|
|
@@ -358,6 +368,11 @@ It could be possible to document (and implement a nice interface for) this query
|
|
|
358
368
|
|
|
359
369
|
### Release a new version
|
|
360
370
|
|
|
361
|
-
1. Bump `
|
|
362
|
-
1. `
|
|
363
|
-
1. `
|
|
371
|
+
1. Bump `version` in `pyproject.toml`
|
|
372
|
+
1. `poetry build`
|
|
373
|
+
1. `poetry publish`
|
|
374
|
+
1. Draft release notes in GitHub.
|
|
375
|
+
|
|
376
|
+
## Disclaimer
|
|
377
|
+
|
|
378
|
+
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.
|
|
@@ -6,9 +6,10 @@ import json
|
|
|
6
6
|
import logging
|
|
7
7
|
import random
|
|
8
8
|
import uuid
|
|
9
|
+
import re
|
|
9
10
|
from operator import itemgetter
|
|
10
11
|
from time import sleep
|
|
11
|
-
from urllib.parse import urlencode
|
|
12
|
+
from urllib.parse import urlencode, quote
|
|
12
13
|
from typing import Dict, Union, Optional, List, Literal
|
|
13
14
|
|
|
14
15
|
from linkedin_api.client import Client
|
|
@@ -848,21 +849,165 @@ class Linkedin(object):
|
|
|
848
849
|
|
|
849
850
|
return profile
|
|
850
851
|
|
|
851
|
-
def get_profile_connections(
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
852
|
+
def get_profile_connections(self, urn_id: str, **kwargs) -> List:
|
|
853
|
+
"""Fetch connections for a given LinkedIn profile.
|
|
854
|
+
|
|
855
|
+
See Linkedin.search_people() for additional searching parameters.
|
|
855
856
|
|
|
856
857
|
:param urn_id: LinkedIn URN ID for a profile
|
|
857
858
|
:type urn_id: str
|
|
858
859
|
|
|
859
|
-
:
|
|
860
|
+
:return: List of search results
|
|
861
|
+
:rtype: list
|
|
862
|
+
"""
|
|
863
|
+
return self.search_people(connection_of=urn_id, **kwargs)
|
|
864
|
+
|
|
865
|
+
def get_profile_experiences(self, urn_id: str) -> List:
|
|
866
|
+
"""Fetch experiences for a given LinkedIn profile.
|
|
867
|
+
|
|
868
|
+
NOTE: data structure differs slightly from Linkedin.get_profile() experiences.
|
|
869
|
+
|
|
870
|
+
:param urn_id: LinkedIn URN ID for a profile
|
|
860
871
|
:type urn_id: str
|
|
861
872
|
|
|
862
|
-
:return: List of
|
|
873
|
+
:return: List of experiences
|
|
863
874
|
:rtype: list
|
|
864
875
|
"""
|
|
865
|
-
|
|
876
|
+
profile_urn = f"urn:li:fsd_profile:{urn_id}"
|
|
877
|
+
variables = ",".join(
|
|
878
|
+
[f"profileUrn:{quote(profile_urn)}", "sectionType:experience"]
|
|
879
|
+
)
|
|
880
|
+
query_id = (
|
|
881
|
+
"voyagerIdentityDashProfileComponents.7af5d6f176f11583b382e37e5639e69e"
|
|
882
|
+
)
|
|
883
|
+
|
|
884
|
+
res = self._fetch(
|
|
885
|
+
f"/graphql?variables=({variables})&queryId={query_id}&includeWebMetadata=true",
|
|
886
|
+
headers={"accept": "application/vnd.linkedin.normalized+json+2.1"},
|
|
887
|
+
)
|
|
888
|
+
|
|
889
|
+
def parse_item(item, is_group_item=False):
|
|
890
|
+
"""
|
|
891
|
+
Parse a single experience item.
|
|
892
|
+
|
|
893
|
+
Items as part of an 'experience group' (e.g. a company with multiple positions) have different data structures.
|
|
894
|
+
Therefore, some exceptions need to be made when parsing these items.
|
|
895
|
+
"""
|
|
896
|
+
component = item["components"]["entityComponent"]
|
|
897
|
+
title = component["titleV2"]["text"]["text"]
|
|
898
|
+
subtitle = component["subtitle"]
|
|
899
|
+
company = subtitle["text"].split(" · ")[0] if subtitle else None
|
|
900
|
+
employment_type_parts = subtitle["text"].split(" · ") if subtitle else None
|
|
901
|
+
employment_type = (
|
|
902
|
+
employment_type_parts[1]
|
|
903
|
+
if employment_type_parts and len(employment_type_parts) > 1
|
|
904
|
+
else None
|
|
905
|
+
)
|
|
906
|
+
metadata = component.get("metadata", {}) or {}
|
|
907
|
+
location = metadata.get("text")
|
|
908
|
+
|
|
909
|
+
duration_text = component["caption"]["text"]
|
|
910
|
+
duration_parts = duration_text.split(" · ")
|
|
911
|
+
date_parts = duration_parts[0].split(" - ")
|
|
912
|
+
|
|
913
|
+
duration = (
|
|
914
|
+
duration_parts[1]
|
|
915
|
+
if duration_parts and len(duration_parts) > 1
|
|
916
|
+
else None
|
|
917
|
+
)
|
|
918
|
+
start_date = date_parts[0] if date_parts else None
|
|
919
|
+
end_date = date_parts[1] if date_parts and len(date_parts) > 1 else None
|
|
920
|
+
|
|
921
|
+
sub_components = component["subComponents"]
|
|
922
|
+
fixed_list_component = (
|
|
923
|
+
sub_components["components"][0]["components"]["fixedListComponent"]
|
|
924
|
+
if sub_components
|
|
925
|
+
else None
|
|
926
|
+
)
|
|
927
|
+
|
|
928
|
+
fixed_list_text_component = (
|
|
929
|
+
fixed_list_component["components"][0]["components"]["textComponent"]
|
|
930
|
+
if fixed_list_component
|
|
931
|
+
else None
|
|
932
|
+
)
|
|
933
|
+
|
|
934
|
+
# Extract additional description
|
|
935
|
+
description = (
|
|
936
|
+
fixed_list_text_component["text"]["text"]
|
|
937
|
+
if fixed_list_text_component
|
|
938
|
+
else None
|
|
939
|
+
)
|
|
940
|
+
|
|
941
|
+
# Create a dictionary with the extracted information
|
|
942
|
+
parsed_data = {
|
|
943
|
+
"title": title,
|
|
944
|
+
"companyName": company if not is_group_item else None,
|
|
945
|
+
"employmentType": company if is_group_item else employment_type,
|
|
946
|
+
"locationName": location,
|
|
947
|
+
"duration": duration,
|
|
948
|
+
"startDate": start_date,
|
|
949
|
+
"endDate": end_date,
|
|
950
|
+
"description": description,
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
return parsed_data
|
|
954
|
+
|
|
955
|
+
def get_grouped_item_id(item):
|
|
956
|
+
sub_components = item["components"]["entityComponent"]["subComponents"]
|
|
957
|
+
sub_components_components = (
|
|
958
|
+
sub_components["components"][0]["components"]
|
|
959
|
+
if sub_components
|
|
960
|
+
else None
|
|
961
|
+
)
|
|
962
|
+
paged_list_component_id = (
|
|
963
|
+
sub_components_components.get("*pagedListComponent", "")
|
|
964
|
+
if sub_components_components
|
|
965
|
+
else None
|
|
966
|
+
)
|
|
967
|
+
if (
|
|
968
|
+
paged_list_component_id
|
|
969
|
+
and "fsd_profilePositionGroup" in paged_list_component_id
|
|
970
|
+
):
|
|
971
|
+
pattern = r"urn:li:fsd_profilePositionGroup:\([A-z0-9]+,[A-z0-9]+\)"
|
|
972
|
+
match = re.search(pattern, paged_list_component_id)
|
|
973
|
+
return match.group(0) if match else None
|
|
974
|
+
|
|
975
|
+
data = res.json()
|
|
976
|
+
|
|
977
|
+
items = []
|
|
978
|
+
for item in data["included"][0]["components"]["elements"]:
|
|
979
|
+
grouped_item_id = get_grouped_item_id(item)
|
|
980
|
+
# if the item is part of a group (e.g. a company with multiple positions),
|
|
981
|
+
# find the group items and parse them.
|
|
982
|
+
if grouped_item_id:
|
|
983
|
+
component = item["components"]["entityComponent"]
|
|
984
|
+
# use the company and location from the main item
|
|
985
|
+
company = component["titleV2"]["text"]["text"]
|
|
986
|
+
|
|
987
|
+
location = (
|
|
988
|
+
component["caption"]["text"] if component["caption"] else None
|
|
989
|
+
)
|
|
990
|
+
|
|
991
|
+
# find the group
|
|
992
|
+
group = [
|
|
993
|
+
i
|
|
994
|
+
for i in data["included"]
|
|
995
|
+
if grouped_item_id in i.get("entityUrn", "")
|
|
996
|
+
]
|
|
997
|
+
if not group:
|
|
998
|
+
continue
|
|
999
|
+
for group_item in group[0]["components"]["elements"]:
|
|
1000
|
+
parsed_data = parse_item(group_item, is_group_item=True)
|
|
1001
|
+
parsed_data["companyName"] = company
|
|
1002
|
+
parsed_data["locationName"] = location
|
|
1003
|
+
items.append(parsed_data)
|
|
1004
|
+
continue
|
|
1005
|
+
|
|
1006
|
+
# else, parse the regular item
|
|
1007
|
+
parsed_data = parse_item(item)
|
|
1008
|
+
items.append(parsed_data)
|
|
1009
|
+
|
|
1010
|
+
return items
|
|
866
1011
|
|
|
867
1012
|
def get_company_updates(
|
|
868
1013
|
self,
|
|
@@ -1382,6 +1527,13 @@ class Linkedin(object):
|
|
|
1382
1527
|
def get_profile_network_info(self, public_profile_id: str):
|
|
1383
1528
|
"""Fetch network information for a given LinkedIn profile.
|
|
1384
1529
|
|
|
1530
|
+
Network information includes the following:
|
|
1531
|
+
- number of connections
|
|
1532
|
+
- number of followers
|
|
1533
|
+
- if the account is followable
|
|
1534
|
+
- the network distance between the API session user and the profile
|
|
1535
|
+
- if the API session user is following the profile
|
|
1536
|
+
|
|
1385
1537
|
:param public_profile_id: public ID of a LinkedIn profile
|
|
1386
1538
|
:type public_profile_id: str
|
|
1387
1539
|
|
|
@@ -1579,7 +1731,7 @@ class Linkedin(object):
|
|
|
1579
1731
|
results.extend(data["elements"])
|
|
1580
1732
|
self.logger.debug(f"results grew: {len(results)}")
|
|
1581
1733
|
|
|
1582
|
-
return self.
|
|
1734
|
+
return self.get_post_reactions(
|
|
1583
1735
|
urn_id=urn_id,
|
|
1584
1736
|
results=results,
|
|
1585
1737
|
max_results=max_results,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "linkedin-api"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.3.0"
|
|
4
4
|
description = "LinkedIn API for Python"
|
|
5
5
|
authors = ["Tom Quirk <tom@codalabs.au>"]
|
|
6
6
|
maintainers = ["Tom Quirk <tom@codalabs.au>"]
|
|
@@ -28,12 +28,6 @@ sphinx-book-theme = "^1.1.3"
|
|
|
28
28
|
[tool.poetry.group.test.dependencies]
|
|
29
29
|
pytest = "^8.3.2"
|
|
30
30
|
|
|
31
|
-
[tool.poetry.scripts]
|
|
32
|
-
lint = "black --check ."
|
|
33
|
-
test = "python -m pytest tests"
|
|
34
|
-
test_unit = "python -m pytest tests/unit"
|
|
35
|
-
test_e2e = "python -m pytest tests/e2e"
|
|
36
|
-
|
|
37
31
|
[build-system]
|
|
38
32
|
requires = ["poetry-core"]
|
|
39
33
|
build-backend = "poetry.core.masonry.api"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
linkedin-api
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from .linkedin import Linkedin
|
|
6
|
-
|
|
7
|
-
__title__ = "linkedin_api"
|
|
8
|
-
__version__ = "2.2.0"
|
|
9
|
-
__summary__ = "Linkedin API for Python"
|
|
10
|
-
__description__ = "Search profiles, send messages, find jobs, get company posts and more. All with a regular Linkedin user account. Build bots, SDKs, integrations and AI tools."
|
|
11
|
-
__keywords__ = "linkedin,api,automation,scraper,bot,data,sdk,ai,integration,profiles,network,company"
|
|
12
|
-
__license__ = "MIT"
|
|
13
|
-
|
|
14
|
-
__author__ = "Tom Quirk"
|
|
15
|
-
__email__ = "tomquirkacc@gmail.com"
|
|
16
|
-
|
|
17
|
-
__all__ = ["Linkedin"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|