linkedin-api 2.1.0__tar.gz → 2.1.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.
Files changed (21) hide show
  1. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/PKG-INFO +1 -1
  2. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api/__init__.py +2 -1
  3. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api/linkedin.py +41 -19
  4. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api.egg-info/PKG-INFO +1 -1
  5. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/tests/test_linkedin_api_requests.py +13 -19
  6. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/LICENSE +0 -0
  7. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/README.md +0 -0
  8. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api/client.py +0 -0
  9. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api/cookie_repository.py +0 -0
  10. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api/settings.py +0 -0
  11. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api/utils/__init__.py +0 -0
  12. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api/utils/helpers.py +0 -0
  13. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api.egg-info/SOURCES.txt +0 -0
  14. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api.egg-info/dependency_links.txt +0 -0
  15. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api.egg-info/requires.txt +0 -0
  16. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/linkedin_api.egg-info/top_level.txt +0 -0
  17. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/setup.cfg +0 -0
  18. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/setup.py +0 -0
  19. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/tests/test_cookie_repository.py +0 -0
  20. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/tests/test_linkedin_api.py +0 -0
  21. {linkedin_api-2.1.0 → linkedin_api-2.1.1}/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.0
3
+ Version: 2.1.1
4
4
  Summary: Python wrapper for the Linkedin API
5
5
  Home-page: https://github.com/tomquirk/linkedin-api
6
6
  Author: Tom Quirk
@@ -1,10 +1,11 @@
1
1
  """
2
2
  linkedin-api
3
3
  """
4
+
4
5
  from .linkedin import Linkedin
5
6
 
6
7
  __title__ = "linkedin_api"
7
- __version__ = "2.1.0"
8
+ __version__ = "2.1.1"
8
9
  __description__ = "Python Wrapper for the Linkedin API"
9
10
 
10
11
  __license__ = "MIT"
@@ -1,6 +1,7 @@
1
1
  """
2
2
  Provides linkedin api-related code
3
3
  """
4
+
4
5
  import base64
5
6
  import json
6
7
  import logging
@@ -92,6 +93,14 @@ class Linkedin(object):
92
93
  url = f"{self.client.API_BASE_URL if not base_request else self.client.LINKEDIN_BASE_URL}{uri}"
93
94
  return self.client.session.get(url, **kwargs)
94
95
 
96
+ def _cookies(self):
97
+ """Return client cookies"""
98
+ return self.client.cookies
99
+
100
+ def _headers(self):
101
+ """Return client cookies"""
102
+ return self.client.REQUEST_HEADERS
103
+
95
104
  def _post(self, uri, evade=default_evade, base_request=False, **kwargs):
96
105
  """POST request to Linkedin API"""
97
106
  evade()
@@ -221,6 +230,7 @@ class Linkedin(object):
221
230
  "q": "all",
222
231
  "start": len(results) + offset,
223
232
  "queryContext": "List(spellCorrectionEnabled->true,relatedSearchesEnabled->true,kcardTypes->PROFILE|COMPANY)",
233
+ "includeWebMetadata": "true",
224
234
  }
225
235
  default_params.update(params)
226
236
 
@@ -236,7 +246,7 @@ class Linkedin(object):
236
246
  f"{keywords}"
237
247
  f"flagshipSearchIntent:SEARCH_SRP,"
238
248
  f"queryParameters:{default_params['filters']},"
239
- f"includeFiltersInResponse:false))&=&queryId=voyagerSearchDashClusters"
249
+ f"includeFiltersInResponse:false))&queryId=voyagerSearchDashClusters"
240
250
  f".b0928897b71bd00a5a7291755dcd64f0"
241
251
  )
242
252
  data = res.json()
@@ -356,6 +366,8 @@ class Linkedin(object):
356
366
  :type keyword_school: str, optional
357
367
  :param connection_of: Connection of LinkedIn user, given by profile URN ID
358
368
  :type connection_of: str, optional
369
+ :param limit: Maximum length of the returned list, defaults to -1 (no limit)
370
+ :type limit: int, optional
359
371
 
360
372
  :return: List of profiles (minimal data only)
361
373
  :rtype: list
@@ -523,30 +535,30 @@ class Linkedin(object):
523
535
  if limit is None:
524
536
  limit = -1
525
537
 
526
- query = {"origin":"JOB_SEARCH_PAGE_QUERY_EXPANSION"}
538
+ query = {"origin": "JOB_SEARCH_PAGE_QUERY_EXPANSION"}
527
539
  if keywords:
528
540
  query["keywords"] = "KEYWORD_PLACEHOLDER"
529
541
  if location_name:
530
542
  query["locationFallback"] = "LOCATION_PLACEHOLDER"
531
543
 
532
544
  # In selectedFilters()
533
- query['selectedFilters'] = {}
545
+ query["selectedFilters"] = {}
534
546
  if companies:
535
- query['selectedFilters']['company'] = f"List({','.join(companies)})"
547
+ query["selectedFilters"]["company"] = f"List({','.join(companies)})"
536
548
  if experience:
537
- query['selectedFilters']['experience'] = f"List({','.join(experience)})"
549
+ query["selectedFilters"]["experience"] = f"List({','.join(experience)})"
538
550
  if job_type:
539
- query['selectedFilters']['jobType'] = f"List({','.join(job_type)})"
551
+ query["selectedFilters"]["jobType"] = f"List({','.join(job_type)})"
540
552
  if job_title:
541
- query['selectedFilters']['title'] = f"List({','.join(job_title)})"
553
+ query["selectedFilters"]["title"] = f"List({','.join(job_title)})"
542
554
  if industries:
543
- query['selectedFilters']['industry'] = f"List({','.join(industries)})"
555
+ query["selectedFilters"]["industry"] = f"List({','.join(industries)})"
544
556
  if distance:
545
- query['selectedFilters']['distance'] = f"List({distance})"
557
+ query["selectedFilters"]["distance"] = f"List({distance})"
546
558
  if remote:
547
- query['selectedFilters']['workplaceType'] = f"List({','.join(remote)})"
559
+ query["selectedFilters"]["workplaceType"] = f"List({','.join(remote)})"
548
560
 
549
- query['selectedFilters']['timePostedRange'] = f"List(r{listed_at})"
561
+ query["selectedFilters"]["timePostedRange"] = f"List(r{listed_at})"
550
562
  query["spellCorrectionEnabled"] = "true"
551
563
 
552
564
  # Query structure:
@@ -564,12 +576,15 @@ class Linkedin(object):
564
576
  # spellCorrectionEnabled:true
565
577
  # )"
566
578
 
567
- query = str(query).replace(" ","") \
568
- .replace("'","") \
569
- .replace("KEYWORD_PLACEHOLDER", keywords or "") \
570
- .replace("LOCATION_PLACEHOLDER", location_name or "") \
571
- .replace("{","(") \
572
- .replace("}",")")
579
+ query = (
580
+ str(query)
581
+ .replace(" ", "")
582
+ .replace("'", "")
583
+ .replace("KEYWORD_PLACEHOLDER", keywords or "")
584
+ .replace("LOCATION_PLACEHOLDER", location_name or "")
585
+ .replace("{", "(")
586
+ .replace("}", ")")
587
+ )
573
588
  results = []
574
589
  while True:
575
590
  # when we're close to the limit, only fetch what we need to
@@ -593,7 +608,7 @@ class Linkedin(object):
593
608
  new_data = [
594
609
  i
595
610
  for i in elements
596
- if i["$type"] == 'com.linkedin.voyager.dash.jobs.JobPosting'
611
+ if i["$type"] == "com.linkedin.voyager.dash.jobs.JobPosting"
597
612
  ]
598
613
  # break the loop if we're done searching or no results returned
599
614
  if not new_data:
@@ -789,6 +804,13 @@ class Linkedin(object):
789
804
  for item in projects:
790
805
  del item["entityUrn"]
791
806
  profile["projects"] = projects
807
+ # massage [skills] data
808
+ skills = data["skillView"]["elements"]
809
+ for item in skills:
810
+ del item["entityUrn"]
811
+ profile["skills"] = skills
812
+
813
+ profile["urn_id"] = profile["entityUrn"].replace("urn:li:fs_profile:", "")
792
814
 
793
815
  return profile
794
816
 
@@ -1168,7 +1190,7 @@ class Linkedin(object):
1168
1190
  )
1169
1191
 
1170
1192
  res = self._post(
1171
- f"{self.client.API_BASE_URL}/relationships/invitations/{invitation_id}",
1193
+ f"/relationships/invitations/{invitation_id}",
1172
1194
  params=params,
1173
1195
  data=payload,
1174
1196
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linkedin_api
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: Python wrapper for the Linkedin API
5
5
  Home-page: https://github.com/tomquirk/linkedin-api
6
6
  Author: Tom Quirk
@@ -182,7 +182,7 @@ def test_search_jobs(linkedin):
182
182
  # test all filters for correct syntax
183
183
  # location_name -> "san francisco"
184
184
  # companies -> google="1441" or apple="162479"
185
- # experience ->"1", "2", "3", "4", "5" and "6" (internship, entry level, associate, mid-senior level, director and executive, respectively)
185
+ # experience ->"1", "2", "3", "4", "5" and "6" (internship, entry level, associate, mid-senior level, director and executive, respectively)
186
186
  # job_type -> "F", "C", "P", "T", "I", "V", "O" (full-time, contract, part-time, temporary, internship, volunteer and "other", respectively)
187
187
  # job_title -> software_eng="9",cloud_eng="30006"
188
188
  # industries -> computer_hardware="24", it_technology="6"
@@ -190,33 +190,27 @@ def test_search_jobs(linkedin):
190
190
  # remote -> onsite:"1", remote:"2", hybrid:"3"
191
191
  # listed_at -> large number 1000000 seconds
192
192
  jobs = linkedin.search_jobs(
193
- keywords="software engineer",
193
+ keywords="software engineer",
194
194
  location_name="San Francisco",
195
- companies=["1441","162479"],
196
- experience=["1","2","3","4","5","6"],
197
- job_type=["F","C","P","T","I","V","O"],
198
- job_title=["9","30006"],
199
- industries=["24","6"],
195
+ companies=["1441", "162479"],
196
+ experience=["1", "2", "3", "4", "5", "6"],
197
+ job_type=["F", "C", "P", "T", "I", "V", "O"],
198
+ job_title=["9", "30006"],
199
+ industries=["24", "6"],
200
200
  distance=1000,
201
- remote=["1","2","3"],
201
+ remote=["1", "2", "3"],
202
202
  listed_at=1000000,
203
- limit=10
203
+ limit=10,
204
204
  )
205
- assert len(jobs)==10
205
+ assert len(jobs) == 10
206
206
 
207
207
  # Test that no results doesn't return an infinite loop
208
- jobs = linkedin.search_jobs(
209
- keywords="blurp",
210
- location_name="antarctica"
211
- )
212
- assert len(jobs)==0
208
+ jobs = linkedin.search_jobs(keywords="blurp", location_name="antarctica")
209
+ assert len(jobs) == 0
213
210
 
214
211
 
215
212
  def test_get_job(linkedin):
216
- jobs = linkedin.search_jobs(
217
- keywords="software engineer",
218
- limit=1
219
- )
213
+ jobs = linkedin.search_jobs(keywords="software engineer", limit=1)
220
214
  job_id = get_id_from_urn(jobs[0]["trackingUrn"])
221
215
  job_info = linkedin.get_job(job_id)
222
216
  assert job_info
File without changes
File without changes
File without changes
File without changes