99class EmployeeBioFetcher :
1010 def __init__ (self , session ):
1111 self .session = session
12- self .endpoint = "https://www.linkedin.com/voyager/api/graphql?queryId=voyagerIdentityDashProfileComponents.9117695ef207012719e3e0681c667e14 &queryName=ProfileComponentsBySectionType &variables=(tabIndex:0,sectionType:languages, profileUrn:urn%3Ali%3Afsd_profile%3A{employee_id},count:50 )"
12+ self .endpoint = "https://www.linkedin.com/voyager/api/graphql?queryId=voyagerIdentityDashProfileCards.9ad2590cb61a073ad514922fa752f566 &queryName=ProfileTabInitialCards &variables=(count:50, profileUrn:urn%3Ali%3Afsd_profile%3A{employee_id})"
1313
1414 def fetch_employee_bio (self , base_staff ):
1515 ep = self .endpoint .format (employee_id = base_staff .id )
@@ -18,36 +18,19 @@ def fetch_employee_bio(self, base_staff):
1818 if res .status_code == 429 :
1919 return TooManyRequests ("429 Too Many Requests" )
2020 if not res .ok :
21- logger .debug (res .text [: 200 ] )
21+ logger .debug (res .text )
2222 return False
2323 try :
24- res_json = res .json ()
24+ data = res .json ()
2525 except json .decoder .JSONDecodeError :
26- logger .debug (res .text [: 200 ] )
26+ logger .debug (res .text )
2727 return False
2828
2929 try :
30- employee_json = list (
31- filter (
32- lambda x : ",ABOUT," in x ["entityUrn" ],
33- res_json ["data" ]["identityDashProfileCardsByInitialCards" ][
34- "elements"
35- ],
36- )
37- )
30+ base_staff .bio = data ["data" ]["identityDashProfileCardsByInitialCards" ][
31+ "elements"
32+ ][3 ]["topComponents" ][1 ]["components" ]["textComponent" ]["text" ]["text" ]
3833 except (KeyError , IndexError , TypeError ):
39- logger .debug (res_json )
4034 return False
4135
42- self .parse_emp_bio (base_staff , employee_json )
4336 return True
44-
45- def parse_emp_bio (self , emp , emp_dict ):
46- """Parse the employee data from the employee profile."""
47- try :
48- bio = emp_dict [0 ]["topComponents" ][1 ]["components" ]["textComponent" ][
49- "text"
50- ]["text" ]
51- except :
52- bio = None
53- emp .bio = bio
0 commit comments