linkedin-api 2.2.0__tar.gz → 2.2.1__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.
@@ -1,32 +1,61 @@
1
1
  Metadata-Version: 2.1
2
- Name: linkedin_api
3
- Version: 2.2.0
4
- Summary: Python wrapper for the Linkedin API
2
+ Name: linkedin-api
3
+ Version: 2.2.1
4
+ Summary: LinkedIn API for Python
5
5
  Home-page: https://github.com/tomquirk/linkedin-api
6
- Author: Tom Quirk
7
- Author-email: tomquirkacc@gmail.com
8
6
  License: MIT
9
- Classifier: Programming Language :: Python :: 3
7
+ Keywords: linkedin,api,automation,scraper,bot,data,sdk,ai,integration,profiles,network,company
8
+ Author: Tom Quirk
9
+ Author-email: tom@codalabs.au
10
+ Maintainer: Tom Quirk
11
+ Maintainer-email: tom@codalabs.au
12
+ Requires-Python: >=3.10,<4.0
10
13
  Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Dist: beautifulsoup4 (>=4.12.3,<5.0.0)
19
+ Requires-Dist: lxml (>=5.3.0,<6.0.0)
20
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
21
+ Project-URL: Documentation, https://linkedin-api.readthedocs.io
22
+ Project-URL: Repository, https://github.com/tomquirk/linkedin-api
12
23
  Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: requests
15
- Requires-Dist: beautifulsoup4
16
- Requires-Dist: lxml
17
24
 
18
- # Linkedin API for Python
25
+
26
+ <div align="center">
27
+
28
+ # LinkedIn API for Python
29
+ ![Build](https://img.shields.io/github/actions/workflow/status/tomquirk/linkedin-api/ci.yml?label=Build&logo=github) [![GitHub Release](https://img.shields.io/github/v/release/tomquirk/linkedin-api?label=Release&logo=python)](https://pypi.org/project/linkedin-api/) [![License](https://img.shields.io/badge/License-MIT-blue)](#license) [![Documentation](https://img.shields.io/github/v/release/tomquirk/linkedin-api?label=Docs&color=23cc71&logo=readthedocs)](https://linkedin-api.readthedocs.io) [![PyPI Downloads](https://img.shields.io/pypi/dm/linkedin-api?label=Downloads)](https://pypi.org/project/linkedin-api/)
30
+
31
+
32
+ Search profiles, send messages, find jobs and more in Python. No official API access required.
33
+
34
+ <p align="center">
35
+ <a href="https://linkedin-api.readthedocs.io">Documentation</a>
36
+ ·
37
+ <a href="#quick-start">Quick Start</a>
38
+ ·
39
+ <a href="#how-it-works">How it works</a>
40
+ </p>
41
+
42
+ </div>
43
+
44
+ <br>
19
45
 
20
46
  <h3 align="center">Sponsors</h3>
21
47
 
22
- <p align="center" style="margin-bottom:24px" >
48
+ <p align="center" dir="auto" >
49
+ <a href="https://bit.ly/3AFPGZd" target="_blank">
50
+ <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proapis.png" alt="iScraper by ProAPIs">
51
+ </a>
23
52
  <a href="https://bit.ly/3SWnB63" target="_blank">
24
- <img height="45px" style="margin-right:24px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/prospeo.png" alt="Prospeo">
53
+ <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/prospeo.png" alt="Prospeo">
25
54
  </a>
26
55
  <a href="https://bit.ly/3SRximo" target="_blank">
27
- <img height="45px" style="margin-right:24px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proxycurl.png" alt="proxycurl">
56
+ <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proxycurl.png" alt="proxycurl">
28
57
  </a>
29
- <a href="https://bit.ly/3Mbksvd" style="margin-right:24px" target="_blank">
58
+ <a href="https://bit.ly/3Mbksvd" target="_blank">
30
59
  <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/lix.png" alt="Lix">
31
60
  </a>
32
61
  <a href="https://bit.ly/3WOIMrX" target="_blank">
@@ -37,19 +66,28 @@ Requires-Dist: lxml
37
66
  </a>
38
67
  </p>
39
68
 
40
- <h5 align="center"><a href="https://bit.ly/4cCjbIq" target="_blank">Become a sponsor</a></h5>
69
+ <p align="center"><a href="https://bit.ly/4cCjbIq" target="_blank">Become a sponsor</a></p>
41
70
 
42
- ---
71
+ <br>
43
72
 
44
- Programmatically search profiles, send messages, and find jobs. All with a regular Linkedin user account.
73
+ ## Features
45
74
 
46
- No "official" API access required - just use a valid Linkedin account!
75
+ - ✅ No official API access required. Just use a valid LinkedIn user account.
76
+ - ✅ Direct HTTP API interface. No Selenium, Pupeteer, or other browser-based scraping methods.
77
+ - ✅ Get and search people, companies, jobs, posts
78
+ - ✅ Send and retrieve messages
79
+ - ✅ Send and accept connection requests
80
+ - ✅ Get and react to posts
47
81
 
48
- **Caution**: This library is not officially supported by LinkedIn. Using it might violate LinkedIn's Terms of Service. Use it at your own risk.
82
+ And more! [Read the docs](https://linkedin-api.readthedocs.io/en/latest/api.html) for all API methods.
49
83
 
50
84
  ## Installation
51
85
 
52
- > Python >= 3.6 required
86
+ > [!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.
88
+
89
+ > [!NOTE]
90
+ > Python >= 3.8 required
53
91
 
54
92
  To install the linkedin_api package, use the following command:
55
93
 
@@ -65,6 +103,7 @@ pip install git+https://github.com/tomquirk/linkedin-api.git
65
103
 
66
104
  ### Quick Start
67
105
 
106
+ > [!TIP]
68
107
  > See all methods on the [documentation website](https://linkedin-api.readthedocs.io/).
69
108
 
70
109
  The following snippet demonstrates a few basic linkedin_api use cases:
@@ -85,6 +124,12 @@ contact_info = api.get_profile_contact_info('billy-g')
85
124
  connections = api.get_profile_connections('1234asc12304')
86
125
  ```
87
126
 
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
+
88
133
  ## Commercial alternatives
89
134
 
90
135
  > This is a sponsored section
@@ -172,18 +217,36 @@ Scrape Any Data from LinkedIn, without limit with [ScrapIn API](https://bit.ly/4
172
217
  - Interactive API documentation
173
218
  - A highly stable API, backed by over 4 years of experience in data provisioning, with the added reliability of two additional data provider brands owned by the company behind ScrapIn.
174
219
 
175
- Try it for free. [Get your API key now](https://bit.ly/4fUyE9J)
176
-
220
+ Try it for free. [Get your API key now](https://bit.ly/4fUyE9J)
177
221
 
178
222
  </details>
179
223
 
180
- > End sponsored section
224
+ <h3>
225
+ <a href="https://bit.ly/3AFPGZd">
226
+ iScraper by ProAPIs, Inc.
227
+ </a>
228
+ </h3>
181
229
 
182
- ## Documentation
230
+ Access high-quality, real-time LinkedIn data at scale with [iScraper API](https://bit.ly/3AFPGZd), offering unlimited scalability and unmatched accuracy.
183
231
 
184
- For comprehensive documentation, including available methods and parameters, visit the [documentation](https://linkedin-api.readthedocs.io/).
232
+ <details>
185
233
 
186
- [Learn more](#how-it-works) about how it works.
234
+ <summary>Learn more</summary>
235
+
236
+ - Real-time LinkedIn data scraping with unmatched accuracy
237
+ - Hosted datasets with powerful Lucene search access
238
+ - Designed for enterprise and corporate-level applications
239
+ - Handles millions of scrapes per day, ensuring unlimited scalability
240
+ - Trusted by top enterprises for mission-critical data needs
241
+ - Interactive API documentation built on OpenAPI 3 specs for seamless integration
242
+ - Backed by over 10 years of experience in real-time data provisioning
243
+ - Lowest price guarantee for high volume use
244
+
245
+ Get started [here](https://bit.ly/3AFPGZd).
246
+
247
+ </details>
248
+
249
+ > End sponsored section
187
250
 
188
251
  ## Disclaimer
189
252
 
@@ -236,11 +299,11 @@ Please add more as you come across them.
236
299
 
237
300
  ## How it works
238
301
 
239
- This project attempts to provide a simple Python interface for the Linkedin API.
302
+ This project attempts to provide a simple Python interface for the LinkedIn API.
240
303
 
241
- > Do you mean the [legit Linkedin API](https://developer.linkedin.com/)?
304
+ > Do you mean the [legit LinkedIn API](https://developer.linkedin.com/)?
242
305
 
243
- 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.
306
+ 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.
244
307
 
245
308
  This project aims to provide complete coverage for Voyager.
246
309
 
@@ -264,11 +327,11 @@ https://www.linkedin.com/voyager/api /identity/profileView/tom-quirk
264
327
 
265
328
  They are authenticated with a simple cookie, which we send with every request, along with a bunch of headers.
266
329
 
267
- To get a cookie, we POST a given username and password (of a valid Linkedin user account) to `https://www.linkedin.com/uas/authenticate`.
330
+ To get a cookie, we POST a given username and password (of a valid LinkedIn user account) to `https://www.linkedin.com/uas/authenticate`.
268
331
 
269
332
  ### Find new endpoints
270
333
 
271
- We're looking at the Linkedin website and we spot some data we want. What now?
334
+ We're looking at the LinkedIn website and we spot some data we want. What now?
272
335
 
273
336
  The following describes the most reliable method to find relevant endpoints:
274
337
 
@@ -322,3 +385,4 @@ It could be possible to document (and implement a nice interface for) this query
322
385
  1. Bump `__version__` in `__init__.py`
323
386
  1. `pipenv run build`
324
387
  1. `pipenv run publish`
388
+
@@ -1,32 +1,37 @@
1
- Metadata-Version: 2.1
2
- Name: linkedin_api
3
- Version: 2.2.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
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: requests
15
- Requires-Dist: beautifulsoup4
16
- Requires-Dist: lxml
17
-
18
- # Linkedin API for Python
1
+
2
+ <div align="center">
3
+
4
+ # LinkedIn API for Python
5
+ ![Build](https://img.shields.io/github/actions/workflow/status/tomquirk/linkedin-api/ci.yml?label=Build&logo=github) [![GitHub Release](https://img.shields.io/github/v/release/tomquirk/linkedin-api?label=Release&logo=python)](https://pypi.org/project/linkedin-api/) [![License](https://img.shields.io/badge/License-MIT-blue)](#license) [![Documentation](https://img.shields.io/github/v/release/tomquirk/linkedin-api?label=Docs&color=23cc71&logo=readthedocs)](https://linkedin-api.readthedocs.io) [![PyPI Downloads](https://img.shields.io/pypi/dm/linkedin-api?label=Downloads)](https://pypi.org/project/linkedin-api/)
6
+
7
+
8
+ Search profiles, send messages, find jobs and more in Python. No official API access required.
9
+
10
+ <p align="center">
11
+ <a href="https://linkedin-api.readthedocs.io">Documentation</a>
12
+ ·
13
+ <a href="#quick-start">Quick Start</a>
14
+ ·
15
+ <a href="#how-it-works">How it works</a>
16
+ </p>
17
+
18
+ </div>
19
+
20
+ <br>
19
21
 
20
22
  <h3 align="center">Sponsors</h3>
21
23
 
22
- <p align="center" style="margin-bottom:24px" >
24
+ <p align="center" dir="auto" >
25
+ <a href="https://bit.ly/3AFPGZd" target="_blank">
26
+ <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proapis.png" alt="iScraper by ProAPIs">
27
+ </a>
23
28
  <a href="https://bit.ly/3SWnB63" target="_blank">
24
- <img height="45px" style="margin-right:24px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/prospeo.png" alt="Prospeo">
29
+ <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/prospeo.png" alt="Prospeo">
25
30
  </a>
26
31
  <a href="https://bit.ly/3SRximo" target="_blank">
27
- <img height="45px" style="margin-right:24px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proxycurl.png" alt="proxycurl">
32
+ <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proxycurl.png" alt="proxycurl">
28
33
  </a>
29
- <a href="https://bit.ly/3Mbksvd" style="margin-right:24px" target="_blank">
34
+ <a href="https://bit.ly/3Mbksvd" target="_blank">
30
35
  <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/lix.png" alt="Lix">
31
36
  </a>
32
37
  <a href="https://bit.ly/3WOIMrX" target="_blank">
@@ -37,19 +42,28 @@ Requires-Dist: lxml
37
42
  </a>
38
43
  </p>
39
44
 
40
- <h5 align="center"><a href="https://bit.ly/4cCjbIq" target="_blank">Become a sponsor</a></h5>
45
+ <p align="center"><a href="https://bit.ly/4cCjbIq" target="_blank">Become a sponsor</a></p>
41
46
 
42
- ---
47
+ <br>
43
48
 
44
- Programmatically search profiles, send messages, and find jobs. All with a regular Linkedin user account.
49
+ ## Features
45
50
 
46
- No "official" API access required - just use a valid Linkedin account!
51
+ - ✅ No official API access required. Just use a valid LinkedIn user account.
52
+ - ✅ Direct HTTP API interface. No Selenium, Pupeteer, or other browser-based scraping methods.
53
+ - ✅ Get and search people, companies, jobs, posts
54
+ - ✅ Send and retrieve messages
55
+ - ✅ Send and accept connection requests
56
+ - ✅ Get and react to posts
47
57
 
48
- **Caution**: This library is not officially supported by LinkedIn. Using it might violate LinkedIn's Terms of Service. Use it at your own risk.
58
+ And more! [Read the docs](https://linkedin-api.readthedocs.io/en/latest/api.html) for all API methods.
49
59
 
50
60
  ## Installation
51
61
 
52
- > Python >= 3.6 required
62
+ > [!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.
64
+
65
+ > [!NOTE]
66
+ > Python >= 3.8 required
53
67
 
54
68
  To install the linkedin_api package, use the following command:
55
69
 
@@ -65,6 +79,7 @@ pip install git+https://github.com/tomquirk/linkedin-api.git
65
79
 
66
80
  ### Quick Start
67
81
 
82
+ > [!TIP]
68
83
  > See all methods on the [documentation website](https://linkedin-api.readthedocs.io/).
69
84
 
70
85
  The following snippet demonstrates a few basic linkedin_api use cases:
@@ -85,6 +100,12 @@ contact_info = api.get_profile_contact_info('billy-g')
85
100
  connections = api.get_profile_connections('1234asc12304')
86
101
  ```
87
102
 
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
+
88
109
  ## Commercial alternatives
89
110
 
90
111
  > This is a sponsored section
@@ -172,18 +193,36 @@ Scrape Any Data from LinkedIn, without limit with [ScrapIn API](https://bit.ly/4
172
193
  - Interactive API documentation
173
194
  - A highly stable API, backed by over 4 years of experience in data provisioning, with the added reliability of two additional data provider brands owned by the company behind ScrapIn.
174
195
 
175
- Try it for free. [Get your API key now](https://bit.ly/4fUyE9J)
176
-
196
+ Try it for free. [Get your API key now](https://bit.ly/4fUyE9J)
177
197
 
178
198
  </details>
179
199
 
180
- > End sponsored section
200
+ <h3>
201
+ <a href="https://bit.ly/3AFPGZd">
202
+ iScraper by ProAPIs, Inc.
203
+ </a>
204
+ </h3>
181
205
 
182
- ## Documentation
206
+ Access high-quality, real-time LinkedIn data at scale with [iScraper API](https://bit.ly/3AFPGZd), offering unlimited scalability and unmatched accuracy.
183
207
 
184
- For comprehensive documentation, including available methods and parameters, visit the [documentation](https://linkedin-api.readthedocs.io/).
208
+ <details>
185
209
 
186
- [Learn more](#how-it-works) about how it works.
210
+ <summary>Learn more</summary>
211
+
212
+ - Real-time LinkedIn data scraping with unmatched accuracy
213
+ - Hosted datasets with powerful Lucene search access
214
+ - Designed for enterprise and corporate-level applications
215
+ - Handles millions of scrapes per day, ensuring unlimited scalability
216
+ - Trusted by top enterprises for mission-critical data needs
217
+ - Interactive API documentation built on OpenAPI 3 specs for seamless integration
218
+ - Backed by over 10 years of experience in real-time data provisioning
219
+ - Lowest price guarantee for high volume use
220
+
221
+ Get started [here](https://bit.ly/3AFPGZd).
222
+
223
+ </details>
224
+
225
+ > End sponsored section
187
226
 
188
227
  ## Disclaimer
189
228
 
@@ -236,11 +275,11 @@ Please add more as you come across them.
236
275
 
237
276
  ## How it works
238
277
 
239
- This project attempts to provide a simple Python interface for the Linkedin API.
278
+ This project attempts to provide a simple Python interface for the LinkedIn API.
240
279
 
241
- > Do you mean the [legit Linkedin API](https://developer.linkedin.com/)?
280
+ > Do you mean the [legit LinkedIn API](https://developer.linkedin.com/)?
242
281
 
243
- 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.
282
+ 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.
244
283
 
245
284
  This project aims to provide complete coverage for Voyager.
246
285
 
@@ -264,11 +303,11 @@ https://www.linkedin.com/voyager/api /identity/profileView/tom-quirk
264
303
 
265
304
  They are authenticated with a simple cookie, which we send with every request, along with a bunch of headers.
266
305
 
267
- To get a cookie, we POST a given username and password (of a valid Linkedin user account) to `https://www.linkedin.com/uas/authenticate`.
306
+ To get a cookie, we POST a given username and password (of a valid LinkedIn user account) to `https://www.linkedin.com/uas/authenticate`.
268
307
 
269
308
  ### Find new endpoints
270
309
 
271
- We're looking at the Linkedin website and we spot some data we want. What now?
310
+ We're looking at the LinkedIn website and we spot some data we want. What now?
272
311
 
273
312
  The following describes the most reliable method to find relevant endpoints:
274
313
 
@@ -1536,7 +1536,6 @@ class Linkedin(object):
1536
1536
  return {}
1537
1537
 
1538
1538
  return data
1539
-
1540
1539
 
1541
1540
  def get_post_reactions(self, urn_id, max_results=None, results=None):
1542
1541
  """Fetch social reactions for a given LinkedIn post.
@@ -0,0 +1,39 @@
1
+ [tool.poetry]
2
+ name = "linkedin-api"
3
+ version = "2.2.1"
4
+ description = "LinkedIn API for Python"
5
+ authors = ["Tom Quirk <tom@codalabs.au>"]
6
+ maintainers = ["Tom Quirk <tom@codalabs.au>"]
7
+ license = "MIT"
8
+ readme = "README.md"
9
+ homepage = "https://github.com/tomquirk/linkedin-api"
10
+ repository = "https://github.com/tomquirk/linkedin-api"
11
+ documentation = "https://linkedin-api.readthedocs.io"
12
+ keywords = ["linkedin", "api", "automation", "scraper", "bot", "data", "sdk", "ai", "integration", "profiles", "network", "company"]
13
+ packages = [{include = "linkedin_api"}]
14
+
15
+ [tool.poetry.dependencies]
16
+ python = "^3.10"
17
+ requests = "^2.32.3"
18
+ beautifulsoup4 = "^4.12.3"
19
+ lxml = "^5.3.0"
20
+
21
+ [tool.poetry.group.dev.dependencies]
22
+ black = "^24.8.0"
23
+
24
+ [tool.poetry.group.docs.dependencies]
25
+ sphinx = "^8.0.2"
26
+ sphinx-book-theme = "^1.1.3"
27
+
28
+ [tool.poetry.group.test.dependencies]
29
+ pytest = "^8.3.2"
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
+ [build-system]
38
+ requires = ["poetry-core"]
39
+ build-backend = "poetry.core.masonry.api"
@@ -1,307 +0,0 @@
1
- # Linkedin API for Python
2
-
3
- <h3 align="center">Sponsors</h3>
4
-
5
- <p align="center" style="margin-bottom:24px" >
6
- <a href="https://bit.ly/3SWnB63" target="_blank">
7
- <img height="45px" style="margin-right:24px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/prospeo.png" alt="Prospeo">
8
- </a>
9
- <a href="https://bit.ly/3SRximo" target="_blank">
10
- <img height="45px" style="margin-right:24px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proxycurl.png" alt="proxycurl">
11
- </a>
12
- <a href="https://bit.ly/3Mbksvd" style="margin-right:24px" target="_blank">
13
- <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/lix.png" alt="Lix">
14
- </a>
15
- <a href="https://bit.ly/3WOIMrX" target="_blank">
16
- <img height="70px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/unipile.png" alt="Unipile">
17
- </a>
18
- <a href="https://bit.ly/4fUyE9J" target="_blank">
19
- <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/scrapin.png" alt="Scrapin">
20
- </a>
21
- </p>
22
-
23
- <h5 align="center"><a href="https://bit.ly/4cCjbIq" target="_blank">Become a sponsor</a></h5>
24
-
25
- ---
26
-
27
- Programmatically search profiles, send messages, and find jobs. All with a regular Linkedin user account.
28
-
29
- No "official" API access required - just use a valid Linkedin account!
30
-
31
- **Caution**: This library is not officially supported by LinkedIn. Using it might violate LinkedIn's Terms of Service. Use it at your own risk.
32
-
33
- ## Installation
34
-
35
- > Python >= 3.6 required
36
-
37
- To install the linkedin_api package, use the following command:
38
-
39
- ```bash
40
- pip install linkedin-api
41
- ```
42
-
43
- Or, for bleading edge:
44
-
45
- ```bash
46
- pip install git+https://github.com/tomquirk/linkedin-api.git
47
- ```
48
-
49
- ### Quick Start
50
-
51
- > See all methods on the [documentation website](https://linkedin-api.readthedocs.io/).
52
-
53
- The following snippet demonstrates a few basic linkedin_api use cases:
54
-
55
- ```python
56
- from linkedin_api import Linkedin
57
-
58
- # Authenticate using any Linkedin account credentials
59
- api = Linkedin('reedhoffman@linkedin.com', '*******')
60
-
61
- # GET a profile
62
- profile = api.get_profile('billy-g')
63
-
64
- # GET a profiles contact info
65
- contact_info = api.get_profile_contact_info('billy-g')
66
-
67
- # GET 1st degree connections of a given profile
68
- connections = api.get_profile_connections('1234asc12304')
69
- ```
70
-
71
- ## Commercial alternatives
72
-
73
- > This is a sponsored section
74
-
75
- <h3>
76
- <a href="https://prospeo.io/api/linkedin-email-finder">
77
- Prospeo
78
- </a>
79
- </h3>
80
-
81
- Extract data and find verified emails in real-time with [Prospeo LinkedIn Email Finder API](https://prospeo.io/api/linkedin-email-finder).
82
-
83
- <details>
84
- <summary>Learn more</summary>
85
- Submit a LinkedIn profile URL to our API and get:
86
-
87
- - Profile data extracted in real-time
88
- - Company data of the profile
89
- - Verified work email of the profile
90
- - Exclusive data points (gender, cleaned country code, time zone...)
91
- - One do-it-all request
92
- - Stable API, tested under high load
93
-
94
- Try it with 75 profiles. [Get your FREE API key now](https://prospeo.io/api/linkedin-email-finder).
95
-
96
- </details>
97
-
98
- <h3>
99
- <a href="https://nubela.co/proxycurl/?utm_campaign=influencer%20marketing&utm_source=github&utm_medium=social&utm_term=-&utm_content=tom%20quirk">
100
- Proxycurl
101
- </a>
102
- </h3>
103
-
104
- 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).
105
-
106
- <details>
107
- <summary>Learn more</summary>
108
-
109
- - Scraping Public profiles are battle tested in court in HiQ VS LinkedIn case.
110
- - GDPR, CCPA, SOC2 compliant
111
- - High rate limit - 300 requests/minute
112
- - Fast - APIs respond in ~2s
113
- - Fresh data - 88% of data is scraped real-time, other 12% are not older than 29 days
114
- - High accuracy
115
- - Tons of data points returned per profile
116
-
117
- Built for developers, by developers.
118
-
119
- </details>
120
-
121
- <h3>
122
- <a href="https://www.unipile.com/communication-api/messaging-api/linkedin-api/?utm_campaign=git%20tom%20quirk">
123
- Unipile
124
- </a>
125
- </h3>
126
-
127
- Full [LinkedIn API](https://www.unipile.com/communication-api/messaging-api/linkedin-api/?utm_campaign=git%20tom%20quirk): Connect Classic/Sales Navigator/Recruiter, synchronize real-time messaging, enrich data and build outreach sequences…
128
-
129
- <details>
130
- <summary>Learn more</summary>
131
-
132
- - Easily connect your users in the cloud with our white-label authentication (captcha solving, in-app validation, OTP, 2FA).
133
- - Real-time webhook for each message received, read status, invitation accepted, and more.
134
- - Data extraction: get profile, get company, get post, extract search results from Classic + Sales Navigator + Recruiter
135
- - Outreach sequences: send invitations, InMail, messages, and comment on posts…
136
-
137
- Test [all the features](https://www.unipile.com/communication-api/messaging-api/linkedin-api/?utm_campaign=git%20tom%20quirk) with our 7-day free trial.
138
-
139
- </details>
140
-
141
- <h3>
142
- <a href="https://bit.ly/4fUyE9J">
143
- ScrapIn
144
- </a>
145
- </h3>
146
-
147
- Scrape Any Data from LinkedIn, without limit with [ScrapIn API](https://bit.ly/4fUyE9J).
148
-
149
- <details>
150
- <summary>Learn more</summary>
151
-
152
- - Real time data (no-cache)
153
- - Built for SaaS developers
154
- - GDPR, CCPA, SOC2 compliant
155
- - Interactive API documentation
156
- - A highly stable API, backed by over 4 years of experience in data provisioning, with the added reliability of two additional data provider brands owned by the company behind ScrapIn.
157
-
158
- Try it for free. [Get your API key now](https://bit.ly/4fUyE9J)
159
-
160
-
161
- </details>
162
-
163
- > End sponsored section
164
-
165
- ## Documentation
166
-
167
- For comprehensive documentation, including available methods and parameters, visit the [documentation](https://linkedin-api.readthedocs.io/).
168
-
169
- [Learn more](#how-it-works) about how it works.
170
-
171
- ## Disclaimer
172
-
173
- 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.
174
-
175
- ## Contributing
176
-
177
- We welcome contributions! [Learn how to find endpoints](#find-new-endpoints).
178
-
179
- ## Development
180
-
181
- ### Dependencies
182
-
183
- - Python 3.7
184
- - A valid Linkedin user account (don't use your personal account, if possible)
185
- - [`pipenv`](https://pipenv.pypa.io/en/latest/) (optional)
186
-
187
- ### Development installation
188
-
189
- 1. Create a `.env` config file. An example is provided in `.env.example` - you include at least all of the settings set there.
190
- 2. Install dependencies with `pipenv`:
191
-
192
- ```bash
193
- pipenv install --dev
194
- pipenv shell
195
- ```
196
-
197
- ### Run tests
198
-
199
- ```bash
200
- pipenv run test
201
- ```
202
-
203
- ### Troubleshooting
204
-
205
- #### I keep getting a `CHALLENGE`
206
-
207
- 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.
208
-
209
- **Known reasons for Challenge** include:
210
-
211
- - 2FA
212
- - 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.
213
-
214
- Please add more as you come across them.
215
-
216
- #### Search problems
217
-
218
- - 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.
219
-
220
- ## How it works
221
-
222
- This project attempts to provide a simple Python interface for the Linkedin API.
223
-
224
- > Do you mean the [legit Linkedin API](https://developer.linkedin.com/)?
225
-
226
- 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.
227
-
228
- This project aims to provide complete coverage for Voyager.
229
-
230
- [How does it work?](#deep-dive)
231
-
232
- ### Deep dive
233
-
234
- Voyager endpoints look like this:
235
-
236
- ```text
237
- https://www.linkedin.com/voyager/api/identity/profileView/tom-quirk
238
- ```
239
-
240
- Or, more clearly
241
-
242
- ```text
243
- ___________________________________ _______________________________
244
- | base path | resource |
245
- https://www.linkedin.com/voyager/api /identity/profileView/tom-quirk
246
- ```
247
-
248
- They are authenticated with a simple cookie, which we send with every request, along with a bunch of headers.
249
-
250
- To get a cookie, we POST a given username and password (of a valid Linkedin user account) to `https://www.linkedin.com/uas/authenticate`.
251
-
252
- ### Find new endpoints
253
-
254
- We're looking at the Linkedin website and we spot some data we want. What now?
255
-
256
- The following describes the most reliable method to find relevant endpoints:
257
-
258
- 1. `view source`
259
- 1. `command-f`/search the page for some keyword in the data. This will exist inside of a `<code>` tag.
260
- 1. Scroll down to the **next adjacent element** which will be another `<code>` tag, probably with an `id` that looks something like
261
-
262
- ```html
263
- <code style="display: none" id="datalet-bpr-guid-3900675">
264
- {"request":"/voyager/api/identity/profiles/tom-quirk/profileView","status":200,"body":"bpr-guid-3900675"}
265
- </code>
266
- ```
267
-
268
- The value of `request` is the url! 🤘
269
-
270
- You can also use the `network` tab in you browsers developer tools, but you will encounter mixed results.
271
-
272
- ### How Clients query Voyager
273
-
274
- linkedin.com uses the [Rest-li Protocol](https://linkedin.github.io/rest.li/spec/protocol) for querying data. Rest-li is an internal query language/syntax where clients (like linkedin.com) specify what data they want. It's conceptually similar to the GraphQL.
275
-
276
- Here's an example of making a request for an organisation's `name` and `groups` (the Linkedin groups it manages):
277
-
278
- ```text
279
- /voyager/api/organization/companies?decoration=(name,groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url))&q=universalName&universalName=linkedin
280
- ```
281
-
282
- The "querying" happens in the `decoration` parameter, which looks like the following:
283
-
284
- ```text
285
- (
286
- name,
287
- groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url)
288
- )
289
- ```
290
-
291
- Here, we request an organisation name and a list of groups, where for each group we want `largeLogo`, `groupName`, and so on.
292
-
293
- 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.
294
-
295
- In contrast, the `/search/cluster` endpoint uses `q=guided`, and specifies its query with the `guided` parameter, whose value is something like
296
-
297
- ```text
298
- List(v->PEOPLE)
299
- ```
300
-
301
- 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).
302
-
303
- ### Release a new version
304
-
305
- 1. Bump `__version__` in `__init__.py`
306
- 1. `pipenv run build`
307
- 1. `pipenv run publish`
@@ -1,19 +0,0 @@
1
- LICENSE
2
- README.md
3
- setup.py
4
- linkedin_api/__init__.py
5
- linkedin_api/client.py
6
- linkedin_api/cookie_repository.py
7
- linkedin_api/linkedin.py
8
- linkedin_api/settings.py
9
- linkedin_api.egg-info/PKG-INFO
10
- linkedin_api.egg-info/SOURCES.txt
11
- linkedin_api.egg-info/dependency_links.txt
12
- linkedin_api.egg-info/requires.txt
13
- linkedin_api.egg-info/top_level.txt
14
- linkedin_api/utils/__init__.py
15
- linkedin_api/utils/helpers.py
16
- tests/test_cookie_repository.py
17
- tests/test_linkedin_api.py
18
- tests/test_linkedin_api_requests.py
19
- tests/test_linkedin_client.py
@@ -1,3 +0,0 @@
1
- requests
2
- beautifulsoup4
3
- lxml
@@ -1 +0,0 @@
1
- linkedin_api
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,41 +0,0 @@
1
- import setuptools
2
- import ast
3
- import re
4
- from pathlib import Path
5
-
6
- CURRENT_DIR = Path(__file__).parent
7
-
8
-
9
- def get_long_description() -> str:
10
- readme_md = CURRENT_DIR / "README.md"
11
- with open(readme_md, encoding="utf8") as ld_file:
12
- return ld_file.read()
13
-
14
-
15
- def get_version() -> str:
16
- black_py = CURRENT_DIR / "linkedin_api/__init__.py"
17
- _version_re = re.compile(r"__version__\s+=\s+(?P<version>.*)")
18
- with open(black_py, "r", encoding="utf8") as f:
19
- match = _version_re.search(f.read())
20
- version = match.group("version") if match is not None else '"unknown"'
21
- return str(ast.literal_eval(version))
22
-
23
-
24
- setuptools.setup(
25
- name="linkedin_api",
26
- version=get_version(),
27
- author="Tom Quirk",
28
- author_email="tomquirkacc@gmail.com",
29
- description="Python wrapper for the Linkedin API",
30
- long_description=get_long_description(),
31
- long_description_content_type="text/markdown",
32
- url="https://github.com/tomquirk/linkedin-api",
33
- license="MIT",
34
- packages=setuptools.find_packages(),
35
- install_requires=["requests", "beautifulsoup4", "lxml"],
36
- classifiers=[
37
- "Programming Language :: Python :: 3",
38
- "License :: OSI Approved :: MIT License",
39
- "Operating System :: OS Independent",
40
- ],
41
- )
@@ -1,53 +0,0 @@
1
- import os
2
- import sys
3
- import pytest
4
- import requests
5
- from datetime import datetime
6
-
7
- from linkedin_api.cookie_repository import (
8
- CookieRepository,
9
- LinkedinSessionExpired,
10
- )
11
-
12
-
13
- def mock_cookies(date=datetime.strptime("2050-05-04", "%Y-%m-%d")):
14
- jar = requests.cookies.RequestsCookieJar()
15
- jar.set(
16
- "JSESSIONID",
17
- "1234",
18
- expires=date.timestamp(),
19
- domain="httpbin.org",
20
- path="/cookies",
21
- )
22
- return jar
23
-
24
-
25
- def test_save():
26
- repo = CookieRepository()
27
- repo.save(mock_cookies(), "testuser")
28
- assert True
29
-
30
-
31
- def test_get():
32
- repo = CookieRepository()
33
- c = repo.get("testuser")
34
- assert c is not None
35
- assert c == mock_cookies()
36
-
37
-
38
- def test_get_nonexistent_file():
39
- repo = CookieRepository()
40
- c = repo.get("ghost")
41
- assert c is None
42
-
43
-
44
- def test_get_expired():
45
- repo = CookieRepository()
46
- repo.save(
47
- mock_cookies(date=datetime.strptime("2001-05-04", "%Y-%m-%d")), "testuserex"
48
- )
49
- try:
50
- repo.get("testuserex")
51
- assert False
52
- except LinkedinSessionExpired:
53
- assert True
@@ -1,10 +0,0 @@
1
- import os
2
- import sys
3
- import pytest
4
-
5
- from linkedin_api import Linkedin
6
-
7
-
8
- def test_constructor():
9
- api = Linkedin("test", "test", authenticate=False)
10
- assert api
@@ -1,350 +0,0 @@
1
- import os
2
- import sys
3
- import pytest
4
-
5
- from linkedin_api import Linkedin
6
- from linkedin_api.utils.helpers import get_id_from_urn
7
-
8
- TEST_LINKEDIN_USERNAME = os.getenv("LINKEDIN_USERNAME")
9
- TEST_LINKEDIN_PASSWORD = os.getenv("LINKEDIN_PASSWORD")
10
- TEST_PROFILE_ID = os.getenv("TEST_PROFILE_ID")
11
- TEST_PUBLIC_PROFILE_ID = os.getenv("TEST_PUBLIC_PROFILE_ID")
12
- TEST_CONVERSATION_ID = os.getenv("TEST_CONVERSATION_ID")
13
-
14
- if not (
15
- TEST_LINKEDIN_USERNAME
16
- and TEST_LINKEDIN_PASSWORD
17
- and TEST_PROFILE_ID
18
- and TEST_PUBLIC_PROFILE_ID
19
- and TEST_CONVERSATION_ID
20
- ):
21
- print("Test config incomplete. Exiting...")
22
- sys.exit()
23
-
24
-
25
- @pytest.fixture(scope="module")
26
- def linkedin():
27
- return Linkedin(
28
- TEST_LINKEDIN_USERNAME, TEST_LINKEDIN_PASSWORD, refresh_cookies=True
29
- )
30
-
31
-
32
- def test_get_profile(linkedin):
33
- profile = linkedin.get_profile(urn_id=TEST_PROFILE_ID)
34
-
35
- assert profile
36
-
37
-
38
- def test_get_profile_privacy_settings(linkedin):
39
- data = linkedin.get_profile_privacy_settings(TEST_PUBLIC_PROFILE_ID)
40
-
41
- assert data
42
-
43
-
44
- def test_get_profile_member_badges(linkedin):
45
- data = linkedin.get_profile_member_badges(TEST_PUBLIC_PROFILE_ID)
46
-
47
- assert data
48
-
49
-
50
- def test_get_profile_network_info(linkedin):
51
- data = linkedin.get_profile_network_info(TEST_PUBLIC_PROFILE_ID)
52
-
53
- assert data
54
-
55
-
56
- def test_get_profile_contact_info(linkedin):
57
- contact_info = linkedin.get_profile_contact_info(TEST_PROFILE_ID)
58
- assert contact_info
59
-
60
-
61
- def test_get_profile_connections(linkedin):
62
- connections = linkedin.get_profile_connections(TEST_PROFILE_ID)
63
- assert connections
64
-
65
-
66
- def test_get_conversations(linkedin):
67
- conversations = linkedin.get_conversations()
68
- assert conversations
69
-
70
-
71
- def test_get_conversation_details(linkedin):
72
- conversation_details = linkedin.get_conversation_details(TEST_PROFILE_ID)
73
- assert conversation_details
74
-
75
-
76
- def test_get_conversation(linkedin):
77
- conversation = linkedin.get_conversation(TEST_CONVERSATION_ID)
78
- assert conversation
79
-
80
-
81
- def test_send_message_to_conversation(linkedin):
82
- err = linkedin.send_message(
83
- conversation_urn_id=TEST_CONVERSATION_ID,
84
- message_body="test message from pytest",
85
- )
86
- assert not err
87
-
88
-
89
- def test_send_message_to_recipients(linkedin):
90
- err = linkedin.send_message(
91
- recipients=[TEST_PROFILE_ID], message_body="test message from pytest"
92
- )
93
- assert not err
94
-
95
-
96
- def test_mark_conversation_as_seen(linkedin):
97
- err = linkedin.mark_conversation_as_seen(TEST_CONVERSATION_ID)
98
- assert not err
99
-
100
-
101
- def test_get_current_profile_views(linkedin):
102
- views = linkedin.get_current_profile_views()
103
- assert views >= 0
104
-
105
-
106
- def test_get_school(linkedin):
107
- school = linkedin.get_school("university-of-queensland")
108
- assert school
109
- assert school["name"] == "The University of Queensland"
110
-
111
-
112
- def test_get_company(linkedin):
113
- company = linkedin.get_company("linkedin")
114
- assert company
115
- assert company["name"] == "LinkedIn"
116
-
117
-
118
- def test_follow_company(linkedin):
119
- company = linkedin.get_company("linkedin")
120
- assert company
121
- assert company["name"] == "LinkedIn"
122
- assert company["followingInfo"]
123
- assert "following" in company["followingInfo"]
124
- assert "dashFollowingStateUrn" in company["followingInfo"]
125
- done = linkedin.follow_company(
126
- company["followingInfo"]["dashFollowingStateUrn"],
127
- not company["followingInfo"]["following"],
128
- )
129
- assert done is True
130
-
131
-
132
- def test_search(linkedin):
133
- results = linkedin.search(
134
- {"keywords": "software"},
135
- limit=10, # arbitrary limit to stop test taking too long
136
- )
137
- assert results
138
-
139
-
140
- @pytest.mark.skip(reason="Limit is broken")
141
- def test_search_pagination(linkedin):
142
- results = linkedin.search({"keywords": "software"}, limit=4)
143
- # according to implementation of functions search_people, search_companies
144
- # limit is valid within the category only. So in every category/type of test
145
- # the number of results shall not exceed a given limit
146
- numbers_in_categories = {}
147
- for result in results:
148
- try:
149
- occurrence = numbers_in_categories[result["_type"]]
150
- except KeyError:
151
- occurrence = 0
152
- numbers_in_categories.update({result["_type"]: occurrence})
153
- occurrence += 1
154
- numbers_in_categories[result["_type"]] = occurrence
155
- assert results
156
- assert max(numbers_in_categories.values()) == 4
157
-
158
-
159
- @pytest.mark.skip(reason="Limit is broken")
160
- def test_search_with_limit(linkedin):
161
- results = linkedin.search({"keywords": "tom"}, limit=1)
162
- assert len(results) == 1
163
-
164
-
165
- def test_search_people(linkedin):
166
- results = linkedin.search_people(
167
- keywords="software",
168
- include_private_profiles=True,
169
- limit=10, # arbitrary limit to stop test taking too long
170
- )
171
- assert results
172
-
173
-
174
- @pytest.mark.skip(reason="Limit is broken")
175
- def test_search_people_with_limit(linkedin):
176
- results = linkedin.search_people(
177
- keywords="software", include_private_profiles=True, limit=1
178
- )
179
- assert results
180
- assert len(results) == 1
181
-
182
-
183
- def test_search_people_by_region(linkedin):
184
- results = linkedin.search_people(
185
- keywords="software",
186
- include_private_profiles=True,
187
- regions=["105080838"],
188
- limit=10, # arbitrary limit to stop test taking too long
189
- )
190
- assert results
191
-
192
-
193
- def test_search_people_by_keywords_filter(linkedin: Linkedin):
194
- results = linkedin.search_people(
195
- keyword_first_name="John",
196
- keyword_last_name="Smith",
197
- include_private_profiles=True,
198
- limit=10, # arbitrary limit to stop test taking too long
199
- )
200
- assert results
201
-
202
-
203
- def test_search_jobs(linkedin):
204
- # test all filters for correct syntax
205
- # location_name -> "san francisco"
206
- # companies -> google="1441" or apple="162479"
207
- # experience ->"1", "2", "3", "4", "5" and "6" (internship, entry level, associate, mid-senior level, director and executive, respectively)
208
- # job_type -> "F", "C", "P", "T", "I", "V", "O" (full-time, contract, part-time, temporary, internship, volunteer and "other", respectively)
209
- # job_title -> software_eng="9",cloud_eng="30006"
210
- # industries -> computer_hardware="24", it_technology="6"
211
- # distance -> big number 1000 miles
212
- # remote -> onsite:"1", remote:"2", hybrid:"3"
213
- # listed_at -> large number 1000000 seconds
214
- jobs = linkedin.search_jobs(
215
- keywords="software engineer",
216
- location_name="San Francisco",
217
- companies=["1441", "162479"],
218
- experience=["1", "2", "3", "4", "5", "6"],
219
- job_type=["F", "C", "P", "T", "I", "V", "O"],
220
- job_title=["9", "30006"],
221
- industries=["24", "6"],
222
- distance=1000,
223
- remote=["1", "2", "3"],
224
- listed_at=1000000,
225
- limit=10,
226
- )
227
- assert jobs
228
-
229
- # Test that no results doesn't return an infinite loop
230
- jobs = linkedin.search_jobs(keywords="blurp", location_name="antarctica")
231
- assert len(jobs) == 0
232
-
233
-
234
- def test_get_job(linkedin):
235
- jobs = linkedin.search_jobs(keywords="software engineer", limit=1)
236
- job_id = get_id_from_urn(jobs[0]["trackingUrn"])
237
- job_info = linkedin.get_job(job_id)
238
- assert job_info
239
-
240
-
241
- def test_search_companies(linkedin):
242
- results = linkedin.search_companies(keywords="linkedin", limit=1)
243
- assert results
244
- assert results[0]["urn_id"] == "1337"
245
-
246
-
247
- def test_search_people_distinct(linkedin):
248
- TEST_NAMES = ["Bill Gates", "Mark Zuckerberg"]
249
- results = [linkedin.search_people(name, limit=2)[0] for name in TEST_NAMES]
250
- assert results[0] != results[1]
251
-
252
-
253
- def test_get_profile_skills(linkedin):
254
- skills = linkedin.get_profile_skills(TEST_PROFILE_ID)
255
- assert skills
256
-
257
-
258
- def test_get_invitiations(linkedin):
259
- invitations = linkedin.get_invitations()
260
- assert len(invitations) >= 0
261
-
262
-
263
- def test_accept_invitation(linkedin):
264
- """
265
- NOTE: this test relies on the existence of invitations. If you'd like to test this
266
- functionality, make sure the test account has at least 1 invitation.
267
- """
268
- invitations = linkedin.get_invitations()
269
- if not invitations:
270
- # If we've got no invitations, just force test to pass
271
- assert True
272
- return
273
- num_invitations = len(invitations)
274
- invite = invitations[0]
275
- invitation_response = linkedin.reply_invitation(
276
- invitation_entity_urn=invite["entityUrn"],
277
- invitation_shared_secret=invite["sharedSecret"],
278
- action="accept",
279
- )
280
- assert invitation_response
281
-
282
- invitations = linkedin.get_invitations()
283
- assert len(invitations) == num_invitations - 1
284
-
285
-
286
- def test_reject_invitation(linkedin):
287
- """
288
- NOTE: this test relies on the existence of invitations. If you'd like to test this
289
- functionality, make sure the test account has at least 1 invitation.
290
- """
291
- invitations = linkedin.get_invitations()
292
- if not invitations:
293
- # If we've got no invitations, just force test to pass
294
- assert True
295
- return
296
- num_invitations = len(invitations)
297
- invite = invitations[0]
298
- invitation_response = linkedin.reply_invitation(
299
- invitation_entity_urn=invite["entityUrn"],
300
- invitation_shared_secret=invite["sharedSecret"],
301
- action="reject",
302
- )
303
- assert invitation_response
304
-
305
- invitations = linkedin.get_invitations()
306
- assert len(invitations) == num_invitations - 1
307
-
308
-
309
- def test_unfollow_entity(linkedin):
310
- urn = f"urn:li:member:ACoAACVmHBkBdk3IYY1uodl8Ht4W79rmdVFccOA"
311
- err = linkedin.unfollow_entity(urn)
312
- assert not err
313
-
314
-
315
- def test_get_feed_posts_pagination(linkedin):
316
- results = linkedin.get_feed_posts(101)
317
- assert results
318
-
319
-
320
- def test_get_feed_posts_pagination_with_limit(linkedin):
321
- results = linkedin.get_feed_posts(4)
322
- # Currently promotions are always removed from results
323
- assert len(results) <= 4
324
-
325
-
326
- def test_get_feed_posts_posts_keys(linkedin):
327
- results = linkedin.get_feed_posts(4)
328
- for i in results:
329
- assert i["author_name"]
330
- assert i["author_profile"]
331
- assert i["content"]
332
- assert i["old"]
333
- assert i["url"]
334
-
335
-
336
- def test_get_feed_posts_urns_contains_no_duplicated(linkedin):
337
- l_posts, l_urns = linkedin._get_list_feed_posts_and_list_feed_urns(101)
338
- assert len(set([x for x in l_urns if l_urns.count(x) > 1])) == 0
339
-
340
-
341
- def test_get_post_reactions(linkedin):
342
- results = linkedin.get_spoast_reactions("urn:li:activity:7234094294368665600")
343
- assert results
344
-
345
-
346
- def test_react_to_post(linkedin):
347
- post = linkedin.get_profile_posts("hubertchristophe", None, 1)[0]
348
- post_urn = post["socialDetail"]["urn"].split(":")[-1]
349
- res = linkedin.react_to_post(post_urn, "PRAISE")
350
- assert res == False
@@ -1,23 +0,0 @@
1
- import pytest
2
- import json
3
- import os
4
- import sys
5
- from linkedin_api.client import Client
6
-
7
- TEST_LINKEDIN_USERNAME = os.getenv("LINKEDIN_USERNAME")
8
- TEST_LINKEDIN_PASSWORD = os.getenv("LINKEDIN_PASSWORD")
9
-
10
- if not (TEST_LINKEDIN_USERNAME and TEST_LINKEDIN_PASSWORD):
11
- print("Test config incomplete. Exiting...")
12
- sys.exit()
13
-
14
-
15
- @pytest.fixture
16
- def client():
17
- return Client()
18
-
19
-
20
- def test_authenticate(client):
21
- client.authenticate(TEST_LINKEDIN_USERNAME, TEST_LINKEDIN_USERNAME)
22
-
23
- assert client.session.cookies
File without changes