This repository has been archived by the owner on Mar 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nubela_service.py
79 lines (61 loc) · 2.43 KB
/
nubela_service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import requests
class NubelaService:
API_KEY = 'API_KEY'
@classmethod
def _fetch(cls, url: str, params: dict = None) -> dict:
header_dic = {'Authorization': 'Bearer ' + cls.API_KEY}
response = requests.get(url,
params=params,
headers=header_dic)
return response.json()
@staticmethod
def _format_company_url(company_id: str):
return f'https://www.linkedin.com/company/{company_id}/'
@staticmethod
def _format_person_url(person_id: str):
return f'https://www.linkedin.com/in/{person_id}/'
@classmethod
def get_company_profile(cls, company_id: str) -> dict:
api_url = 'https://nubela.co/proxycurl/api/linkedin/company'
company_url = cls._format_company_url(company_id=company_id)
params = {
'categories': 'include',
'funding_data': 'include',
'extra': 'include',
'exit_data': 'include',
'acquisitions': 'include',
'url': company_url,
'use_cache': 'if-present',
}
return cls._fetch(url=api_url, params=params)
@classmethod
def get_company_employees(cls, company_id: str) -> dict:
api_url = 'https://nubela.co/proxycurl/api/linkedin/company/employees/'
company_url = cls._format_company_url(company_id=company_id)
params = {
'page_size': '1000',
'employment_status': 'current',
'url': company_url,
}
return cls._fetch(url=api_url, params=params)
@classmethod
def get_person_profile(cls, person_id: str) -> dict:
api_url = 'https://nubela.co/proxycurl/api/v2/linkedin'
person_url = cls._format_person_url(person_id=person_id)
params = {
'url': person_url,
'use_cache': 'if-present',
'skills': 'include',
'inferred_salary': 'include',
'extra': 'include',
}
return cls._fetch(url=api_url, params=params)
if __name__ == '__main__':
company_id = 'microsoft'
company_profile = NubelaService.get_company_profile(company_id=company_id)
print(company_profile)
# company_employees = NubelaService.get_company_employees(company_id=company_id)
# print(company_employees)
# person_id = 'maxim-marshak'
# person_profile = NubelaService.get_person_profile(person_id=person_id)
# print(person_profile)