linkedin-api 2.1.1__tar.gz → 2.2.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.
Files changed (22) hide show
  1. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/PKG-INFO +75 -32
  2. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/README.md +74 -31
  3. linkedin_api-2.2.0/linkedin_api/__init__.py +17 -0
  4. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api/client.py +13 -10
  5. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api/cookie_repository.py +6 -4
  6. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api/linkedin.py +239 -156
  7. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api/utils/helpers.py +22 -15
  8. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api.egg-info/PKG-INFO +75 -32
  9. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/tests/test_linkedin_api_requests.py +52 -18
  10. linkedin_api-2.1.1/linkedin_api/__init__.py +0 -16
  11. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/LICENSE +0 -0
  12. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api/settings.py +0 -0
  13. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api/utils/__init__.py +0 -0
  14. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api.egg-info/SOURCES.txt +0 -0
  15. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api.egg-info/dependency_links.txt +0 -0
  16. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api.egg-info/requires.txt +0 -0
  17. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/linkedin_api.egg-info/top_level.txt +0 -0
  18. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/setup.cfg +0 -0
  19. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/setup.py +0 -0
  20. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/tests/test_cookie_repository.py +0 -0
  21. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/tests/test_linkedin_api.py +0 -0
  22. {linkedin_api-2.1.1 → linkedin_api-2.2.0}/tests/test_linkedin_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linkedin_api
3
- Version: 2.1.1
3
+ Version: 2.2.0
4
4
  Summary: Python wrapper for the Linkedin API
5
5
  Home-page: https://github.com/tomquirk/linkedin-api
6
6
  Author: Tom Quirk
@@ -20,25 +20,28 @@ Requires-Dist: lxml
20
20
  <h3 align="center">Sponsors</h3>
21
21
 
22
22
  <p align="center" style="margin-bottom:24px" >
23
- <a href="https://prospeo.io/api/linkedin-email-finder" target="_blank">
23
+ <a href="https://bit.ly/3SWnB63" target="_blank">
24
24
  <img height="45px" style="margin-right:24px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/prospeo.png" alt="Prospeo">
25
25
  </a>
26
- <a href="https://nubela.co/proxycurl/?utm_campaign=influencer%20marketing&utm_source=github&utm_medium=social&utm_term=-&utm_content=tom%20quirk" target="_blank">
27
- <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proxycurl.png" alt="proxycurl">
26
+ <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">
28
28
  </a>
29
- </p>
30
-
31
- <p align="center">
32
- <a href="https://iscraper.io/" target="_blank">
33
- <img height="35px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/iscraper.png" alt="serpsbot">
29
+ <a href="https://bit.ly/3Mbksvd" style="margin-right:24px" target="_blank">
30
+ <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/lix.png" alt="Lix">
31
+ </a>
32
+ <a href="https://bit.ly/3WOIMrX" target="_blank">
33
+ <img height="70px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/unipile.png" alt="Unipile">
34
+ </a>
35
+ <a href="https://bit.ly/4fUyE9J" target="_blank">
36
+ <img height="45px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/scrapin.png" alt="Scrapin">
34
37
  </a>
35
38
  </p>
36
39
 
37
- <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>
40
+ <h5 align="center"><a href="https://bit.ly/4cCjbIq" target="_blank">Become a sponsor</a></h5>
38
41
 
39
42
  ---
40
43
 
41
- Programmatically send messages, get jobs, and search profiles with a regular Linkedin user account.
44
+ Programmatically search profiles, send messages, and find jobs. All with a regular Linkedin user account.
42
45
 
43
46
  No "official" API access required - just use a valid Linkedin account!
44
47
 
@@ -130,6 +133,48 @@ Scrape public LinkedIn profile data at scale with [Proxycurl APIs](https://nubel
130
133
 
131
134
  Built for developers, by developers.
132
135
 
136
+ </details>
137
+
138
+ <h3>
139
+ <a href="https://www.unipile.com/communication-api/messaging-api/linkedin-api/?utm_campaign=git%20tom%20quirk">
140
+ Unipile
141
+ </a>
142
+ </h3>
143
+
144
+ 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…
145
+
146
+ <details>
147
+ <summary>Learn more</summary>
148
+
149
+ - Easily connect your users in the cloud with our white-label authentication (captcha solving, in-app validation, OTP, 2FA).
150
+ - Real-time webhook for each message received, read status, invitation accepted, and more.
151
+ - Data extraction: get profile, get company, get post, extract search results from Classic + Sales Navigator + Recruiter
152
+ - Outreach sequences: send invitations, InMail, messages, and comment on posts…
153
+
154
+ 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.
155
+
156
+ </details>
157
+
158
+ <h3>
159
+ <a href="https://bit.ly/4fUyE9J">
160
+ ScrapIn
161
+ </a>
162
+ </h3>
163
+
164
+ Scrape Any Data from LinkedIn, without limit with [ScrapIn API](https://bit.ly/4fUyE9J).
165
+
166
+ <details>
167
+ <summary>Learn more</summary>
168
+
169
+ - Real time data (no-cache)
170
+ - Built for SaaS developers
171
+ - GDPR, CCPA, SOC2 compliant
172
+ - Interactive API documentation
173
+ - 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
+
175
+ Try it for free. [Get your API key now](https://bit.ly/4fUyE9J)
176
+
177
+
133
178
  </details>
134
179
 
135
180
  > End sponsored section
@@ -146,30 +191,30 @@ This library is not endorsed or supported by LinkedIn. It is an unofficial libra
146
191
 
147
192
  ## Contributing
148
193
 
149
- We welcome contributions! [Learn how to find endpoints](#to-find-endpoints)
194
+ We welcome contributions! [Learn how to find endpoints](#find-new-endpoints).
150
195
 
151
- ## Development Setup
196
+ ## Development
152
197
 
153
198
  ### Dependencies
154
199
 
155
200
  - Python 3.7
156
201
  - A valid Linkedin user account (don't use your personal account, if possible)
157
- - `pipenv` (optional)
202
+ - [`pipenv`](https://pipenv.pypa.io/en/latest/) (optional)
158
203
 
159
204
  ### Development installation
160
205
 
161
206
  1. Create a `.env` config file. An example is provided in `.env.example` - you include at least all of the settings set there.
162
- 2. Using pipenv...
207
+ 2. Install dependencies with `pipenv`:
163
208
 
164
209
  ```bash
165
210
  pipenv install --dev
166
211
  pipenv shell
167
212
  ```
168
213
 
169
- ### Running tests
214
+ ### Run tests
170
215
 
171
216
  ```bash
172
- python -m pytest tests
217
+ pipenv run test
173
218
  ```
174
219
 
175
220
  ### Troubleshooting
@@ -191,8 +236,6 @@ Please add more as you come across them.
191
236
 
192
237
  ## How it works
193
238
 
194
- > Before using this project, please consult the [Terms and Conditions](#terms-and-conditions) and [Legal Notice](#legal).
195
-
196
239
  This project attempts to provide a simple Python interface for the Linkedin API.
197
240
 
198
241
  > Do you mean the [legit Linkedin API](https://developer.linkedin.com/)?
@@ -201,9 +244,9 @@ NO! To retrieve structured data, the [Linkedin Website](https://linkedin.com) us
201
244
 
202
245
  This project aims to provide complete coverage for Voyager.
203
246
 
204
- [How does it work?](#in-depth-overview)
247
+ [How does it work?](#deep-dive)
205
248
 
206
- ### In-depth overview
249
+ ### Deep dive
207
250
 
208
251
  Voyager endpoints look like this:
209
252
 
@@ -223,15 +266,15 @@ They are authenticated with a simple cookie, which we send with every request, a
223
266
 
224
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`.
225
268
 
226
- ### To find endpoints
269
+ ### Find new endpoints
227
270
 
228
271
  We're looking at the Linkedin website and we spot some data we want. What now?
229
272
 
230
- The most reliable method to find the relevant endpoint is to:
273
+ The following describes the most reliable method to find relevant endpoints:
231
274
 
232
275
  1. `view source`
233
- 2. `command-f`/search the page for some keyword in the data. This will exist inside of a `<code>` tag.
234
- 3. Scroll down to the **next adjacent element** which will be another `<code>` tag, probably with an `id` that looks something like
276
+ 1. `command-f`/search the page for some keyword in the data. This will exist inside of a `<code>` tag.
277
+ 1. Scroll down to the **next adjacent element** which will be another `<code>` tag, probably with an `id` that looks something like
235
278
 
236
279
  ```html
237
280
  <code style="display: none" id="datalet-bpr-guid-3900675">
@@ -239,13 +282,13 @@ The most reliable method to find the relevant endpoint is to:
239
282
  </code>
240
283
  ```
241
284
 
242
- 4. The value of `request` is the url! 🤘
285
+ The value of `request` is the url! 🤘
243
286
 
244
287
  You can also use the `network` tab in you browsers developer tools, but you will encounter mixed results.
245
288
 
246
289
  ### How Clients query Voyager
247
290
 
248
- 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).
291
+ 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.
249
292
 
250
293
  Here's an example of making a request for an organisation's `name` and `groups` (the Linkedin groups it manages):
251
294
 
@@ -253,7 +296,7 @@ Here's an example of making a request for an organisation's `name` and `groups`
253
296
  /voyager/api/organization/companies?decoration=(name,groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url))&q=universalName&universalName=linkedin
254
297
  ```
255
298
 
256
- The "querying" happens in the `decoration` parameter, which looks like
299
+ The "querying" happens in the `decoration` parameter, which looks like the following:
257
300
 
258
301
  ```text
259
302
  (
@@ -262,7 +305,7 @@ The "querying" happens in the `decoration` parameter, which looks like
262
305
  )
263
306
  ```
264
307
 
265
- So here, we request an organisation name, and a list of groups, where for each group we want `largeLogo`, `groupName`, etc.
308
+ Here, we request an organisation name and a list of groups, where for each group we want `largeLogo`, `groupName`, and so on.
266
309
 
267
310
  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.
268
311
 
@@ -274,8 +317,8 @@ List(v->PEOPLE)
274
317
 
275
318
  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).
276
319
 
277
- ### Releasing a new version
320
+ ### Release a new version
278
321
 
279
322
  1. Bump `__version__` in `__init__.py`
280
- 1. `python3 setup.py sdist bdist_wheel`
281
- 1. `python3 -m twine upload dist/*`
323
+ 1. `pipenv run build`
324
+ 1. `pipenv run publish`
@@ -3,25 +3,28 @@
3
3
  <h3 align="center">Sponsors</h3>
4
4
 
5
5
  <p align="center" style="margin-bottom:24px" >
6
- <a href="https://prospeo.io/api/linkedin-email-finder" target="_blank">
6
+ <a href="https://bit.ly/3SWnB63" target="_blank">
7
7
  <img height="45px" style="margin-right:24px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/prospeo.png" alt="Prospeo">
8
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="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/proxycurl.png" alt="proxycurl">
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
11
  </a>
12
- </p>
13
-
14
- <p align="center">
15
- <a href="https://iscraper.io/" target="_blank">
16
- <img height="35px" src="https://raw.githubusercontent.com/tomquirk/linkedin-api/master/assets/logos/iscraper.png" alt="serpsbot">
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">
17
20
  </a>
18
21
  </p>
19
22
 
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>
23
+ <h5 align="center"><a href="https://bit.ly/4cCjbIq" target="_blank">Become a sponsor</a></h5>
21
24
 
22
25
  ---
23
26
 
24
- Programmatically send messages, get jobs, and search profiles with a regular Linkedin user account.
27
+ Programmatically search profiles, send messages, and find jobs. All with a regular Linkedin user account.
25
28
 
26
29
  No "official" API access required - just use a valid Linkedin account!
27
30
 
@@ -113,6 +116,48 @@ Scrape public LinkedIn profile data at scale with [Proxycurl APIs](https://nubel
113
116
 
114
117
  Built for developers, by developers.
115
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
+
116
161
  </details>
117
162
 
118
163
  > End sponsored section
@@ -129,30 +174,30 @@ This library is not endorsed or supported by LinkedIn. It is an unofficial libra
129
174
 
130
175
  ## Contributing
131
176
 
132
- We welcome contributions! [Learn how to find endpoints](#to-find-endpoints)
177
+ We welcome contributions! [Learn how to find endpoints](#find-new-endpoints).
133
178
 
134
- ## Development Setup
179
+ ## Development
135
180
 
136
181
  ### Dependencies
137
182
 
138
183
  - Python 3.7
139
184
  - A valid Linkedin user account (don't use your personal account, if possible)
140
- - `pipenv` (optional)
185
+ - [`pipenv`](https://pipenv.pypa.io/en/latest/) (optional)
141
186
 
142
187
  ### Development installation
143
188
 
144
189
  1. Create a `.env` config file. An example is provided in `.env.example` - you include at least all of the settings set there.
145
- 2. Using pipenv...
190
+ 2. Install dependencies with `pipenv`:
146
191
 
147
192
  ```bash
148
193
  pipenv install --dev
149
194
  pipenv shell
150
195
  ```
151
196
 
152
- ### Running tests
197
+ ### Run tests
153
198
 
154
199
  ```bash
155
- python -m pytest tests
200
+ pipenv run test
156
201
  ```
157
202
 
158
203
  ### Troubleshooting
@@ -174,8 +219,6 @@ Please add more as you come across them.
174
219
 
175
220
  ## How it works
176
221
 
177
- > Before using this project, please consult the [Terms and Conditions](#terms-and-conditions) and [Legal Notice](#legal).
178
-
179
222
  This project attempts to provide a simple Python interface for the Linkedin API.
180
223
 
181
224
  > Do you mean the [legit Linkedin API](https://developer.linkedin.com/)?
@@ -184,9 +227,9 @@ NO! To retrieve structured data, the [Linkedin Website](https://linkedin.com) us
184
227
 
185
228
  This project aims to provide complete coverage for Voyager.
186
229
 
187
- [How does it work?](#in-depth-overview)
230
+ [How does it work?](#deep-dive)
188
231
 
189
- ### In-depth overview
232
+ ### Deep dive
190
233
 
191
234
  Voyager endpoints look like this:
192
235
 
@@ -206,15 +249,15 @@ They are authenticated with a simple cookie, which we send with every request, a
206
249
 
207
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`.
208
251
 
209
- ### To find endpoints
252
+ ### Find new endpoints
210
253
 
211
254
  We're looking at the Linkedin website and we spot some data we want. What now?
212
255
 
213
- The most reliable method to find the relevant endpoint is to:
256
+ The following describes the most reliable method to find relevant endpoints:
214
257
 
215
258
  1. `view source`
216
- 2. `command-f`/search the page for some keyword in the data. This will exist inside of a `<code>` tag.
217
- 3. Scroll down to the **next adjacent element** which will be another `<code>` tag, probably with an `id` that looks something like
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
218
261
 
219
262
  ```html
220
263
  <code style="display: none" id="datalet-bpr-guid-3900675">
@@ -222,13 +265,13 @@ The most reliable method to find the relevant endpoint is to:
222
265
  </code>
223
266
  ```
224
267
 
225
- 4. The value of `request` is the url! 🤘
268
+ The value of `request` is the url! 🤘
226
269
 
227
270
  You can also use the `network` tab in you browsers developer tools, but you will encounter mixed results.
228
271
 
229
272
  ### How Clients query Voyager
230
273
 
231
- 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).
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.
232
275
 
233
276
  Here's an example of making a request for an organisation's `name` and `groups` (the Linkedin groups it manages):
234
277
 
@@ -236,7 +279,7 @@ Here's an example of making a request for an organisation's `name` and `groups`
236
279
  /voyager/api/organization/companies?decoration=(name,groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url))&q=universalName&universalName=linkedin
237
280
  ```
238
281
 
239
- The "querying" happens in the `decoration` parameter, which looks like
282
+ The "querying" happens in the `decoration` parameter, which looks like the following:
240
283
 
241
284
  ```text
242
285
  (
@@ -245,7 +288,7 @@ The "querying" happens in the `decoration` parameter, which looks like
245
288
  )
246
289
  ```
247
290
 
248
- So here, we request an organisation name, and a list of groups, where for each group we want `largeLogo`, `groupName`, etc.
291
+ Here, we request an organisation name and a list of groups, where for each group we want `largeLogo`, `groupName`, and so on.
249
292
 
250
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.
251
294
 
@@ -257,8 +300,8 @@ List(v->PEOPLE)
257
300
 
258
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).
259
302
 
260
- ### Releasing a new version
303
+ ### Release a new version
261
304
 
262
305
  1. Bump `__version__` in `__init__.py`
263
- 1. `python3 setup.py sdist bdist_wheel`
264
- 1. `python3 -m twine upload dist/*`
306
+ 1. `pipenv run build`
307
+ 1. `pipenv run publish`
@@ -0,0 +1,17 @@
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"]
@@ -1,7 +1,8 @@
1
1
  import requests
2
2
  import logging
3
3
  from linkedin_api.cookie_repository import CookieRepository
4
- from bs4 import BeautifulSoup
4
+ from bs4 import BeautifulSoup, Tag
5
+ from requests.cookies import RequestsCookieJar
5
6
  import json
6
7
 
7
8
  logger = logging.getLogger(__name__)
@@ -48,7 +49,7 @@ class Client(object):
48
49
  }
49
50
 
50
51
  def __init__(
51
- self, *, debug=False, refresh_cookies=False, proxies={}, cookies_dir=None
52
+ self, *, debug=False, refresh_cookies=False, proxies={}, cookies_dir: str = ""
52
53
  ):
53
54
  self.session = requests.session()
54
55
  self.session.proxies.update(proxies)
@@ -74,7 +75,7 @@ class Client(object):
74
75
  )
75
76
  return res.cookies
76
77
 
77
- def _set_session_cookies(self, cookies):
78
+ def _set_session_cookies(self, cookies: RequestsCookieJar):
78
79
  """
79
80
  Set cookies of the current session and save them to a file named as the username.
80
81
  """
@@ -87,7 +88,7 @@ class Client(object):
87
88
  def cookies(self):
88
89
  return self.session.cookies
89
90
 
90
- def authenticate(self, username, password):
91
+ def authenticate(self, username: str, password: str):
91
92
  if self._use_cookie_cache:
92
93
  self.logger.debug("Attempting to use cached cookies")
93
94
  cookies = self._cookie_repository.get(username)
@@ -118,9 +119,11 @@ class Client(object):
118
119
  clientApplicationInstanceRaw = soup.find(
119
120
  "meta", attrs={"name": "applicationInstance"}
120
121
  )
121
- if clientApplicationInstanceRaw:
122
- clientApplicationInstanceRaw = (
123
- clientApplicationInstanceRaw.attrs.get("content") or {}
122
+ if clientApplicationInstanceRaw and isinstance(
123
+ clientApplicationInstanceRaw, Tag
124
+ ):
125
+ clientApplicationInstanceRaw = clientApplicationInstanceRaw.attrs.get(
126
+ "content", {}
124
127
  )
125
128
  clientApplicationInstance = json.loads(clientApplicationInstanceRaw)
126
129
  self.metadata["clientApplicationInstance"] = clientApplicationInstance
@@ -128,11 +131,11 @@ class Client(object):
128
131
  clientPageInstanceIdRaw = soup.find(
129
132
  "meta", attrs={"name": "clientPageInstanceId"}
130
133
  )
131
- if clientPageInstanceIdRaw:
132
- clientPageInstanceId = clientPageInstanceIdRaw.attrs.get("content") or {}
134
+ if clientPageInstanceIdRaw and isinstance(clientPageInstanceIdRaw, Tag):
135
+ clientPageInstanceId = clientPageInstanceIdRaw.attrs.get("content", {})
133
136
  self.metadata["clientPageInstanceId"] = clientPageInstanceId
134
137
 
135
- def _do_authentication_request(self, username, password):
138
+ def _do_authentication_request(self, username: str, password: str):
136
139
  """
137
140
  Authenticate with Linkedin.
138
141
 
@@ -2,6 +2,8 @@ import os
2
2
  import pickle
3
3
  import time
4
4
  import linkedin_api.settings as settings
5
+ from requests.cookies import RequestsCookieJar
6
+ from typing import Optional
5
7
 
6
8
 
7
9
  class Error(Exception):
@@ -30,7 +32,7 @@ class CookieRepository(object):
30
32
  with open(cookiejar_filepath, "wb") as f:
31
33
  pickle.dump(cookies, f)
32
34
 
33
- def get(self, username):
35
+ def get(self, username: str) -> Optional[RequestsCookieJar]:
34
36
  cookies = self._load_cookies_from_cache(username)
35
37
  if cookies and not CookieRepository._is_token_still_valid(cookies):
36
38
  raise LinkedinSessionExpired
@@ -41,13 +43,13 @@ class CookieRepository(object):
41
43
  if not os.path.exists(self.cookies_dir):
42
44
  os.makedirs(self.cookies_dir)
43
45
 
44
- def _get_cookies_filepath(self, username):
46
+ def _get_cookies_filepath(self, username) -> str:
45
47
  """
46
48
  Return the absolute path of the cookiejar for a given username
47
49
  """
48
50
  return "{}{}.jr".format(self.cookies_dir, username)
49
51
 
50
- def _load_cookies_from_cache(self, username):
52
+ def _load_cookies_from_cache(self, username: str) -> Optional[RequestsCookieJar]:
51
53
  cookiejar_filepath = self._get_cookies_filepath(username)
52
54
  try:
53
55
  with open(cookiejar_filepath, "rb") as f:
@@ -57,7 +59,7 @@ class CookieRepository(object):
57
59
  return None
58
60
 
59
61
  @staticmethod
60
- def _is_token_still_valid(cookiejar):
62
+ def _is_token_still_valid(cookiejar: RequestsCookieJar):
61
63
  _now = time.time()
62
64
  for cookie in cookiejar:
63
65
  if cookie.name == "JSESSIONID" and cookie.value: