@@ -12,15 +12,15 @@ class CommentFetcher:
12
12
13
13
def __init__ (self , session ):
14
14
self .session = session
15
- self .endpoint = "https://www.linkedin.com/voyager/api/graphql?queryId=voyagerSocialDashComments.200c8ad7e1ad32ba4e5cc827ab5c3193&queryName=SocialDashCommentsBySocialDetail&variables=(origins:List(),sortOrder:REVERSE_CHRONOLOGICAL ,count:100,socialDetailUrn:urn%3Ali%3Afsd_socialDetail%3A%28urn%3Ali%3Aactivity%3A{post_id}%2Curn%3Ali%3Aactivity%3A{post_id}%2Curn%3Ali%3AhighlightedReply%3A-%29,start:{start})"
15
+ self .endpoint = "https://www.linkedin.com/voyager/api/graphql?queryId=voyagerSocialDashComments.200c8ad7e1ad32ba4e5cc827ab5c3193&queryName=SocialDashCommentsBySocialDetail&variables=(origins:List(),sortOrder:RELEVANCE ,count:100,socialDetailUrn:urn%3Ali%3Afsd_socialDetail%3A%28urn%3Ali%3Aactivity%3A{post_id}%2Curn%3Ali%3Aactivity%3A{post_id}%2Curn%3Ali%3AhighlightedReply%3A-%29,start:{start})"
16
16
self .post_id = None
17
17
self .num_commments = 100
18
18
19
19
def fetch_comments (self , post_id : str ):
20
20
all_comments = []
21
21
self .post_id = post_id
22
22
23
- for i in range (0 , 100_000 , self .num_commments ):
23
+ for i in range (0 , 200_000 , self .num_commments ):
24
24
logger .info (f"Fetching comments for post { post_id } , start { i } " )
25
25
26
26
ep = self .endpoint .format (post_id = post_id , start = i )
@@ -61,12 +61,16 @@ def parse_comments(self, comments_json: dict):
61
61
linkedin_id = linkedin_id_match .group (1 ) if linkedin_id_match else None
62
62
63
63
commentary = element .get ("commentary" , {}).get ("text" , "" )
64
+ comment_id = element ["urn" ].split ("," )[- 1 ].rstrip (")" )
65
+ num_likes = element ["socialDetail" ]["totalSocialActivityCounts" ]["numLikes" ]
64
66
comment = Comment (
65
67
post_id = self .post_id ,
68
+ comment_id = comment_id ,
66
69
internal_profile_id = internal_profile_id ,
67
70
public_profile_id = linkedin_id ,
68
71
name = name ,
69
72
text = commentary ,
73
+ num_likes = num_likes ,
70
74
created_at = dt .utcfromtimestamp (element ["createdAt" ] / 1000 ),
71
75
)
72
76
comments .append (comment )
0 commit comments