jonathanjordan21 commited on
Commit
432378a
·
verified ·
1 Parent(s): 5f5602d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -47,13 +47,15 @@ async def linkedin_post_details(post_id: str):
47
  except Exception as e:
48
  continue
49
 
50
- try:
51
- spans = soup.find_all(
52
- "span", {"data-test-id": "social-actions__reaction-count"}
53
- )
54
- except:
 
 
 
55
  reactions = 0
56
- reactions = spans[0].text.strip()
57
 
58
  try:
59
  comments = soup.find("a", {"data-test-id": "social-actions__comments"}).get(
@@ -65,9 +67,9 @@ async def linkedin_post_details(post_id: str):
65
  return {
66
  "insights": {
67
  "likeCount": None,
68
- "commentCount": comments,
69
  "shareCount": None,
70
- "reactionCount": reactions,
71
  "reactions": [],
72
  },
73
  "description": desc,
 
47
  except Exception as e:
48
  continue
49
 
50
+
51
+ spans = soup.find_all(
52
+ "span", {"data-test-id": "social-actions__reaction-count"}
53
+ )
54
+
55
+ if spans:
56
+ reactions = spans[0].text.strip()
57
+ else:
58
  reactions = 0
 
59
 
60
  try:
61
  comments = soup.find("a", {"data-test-id": "social-actions__comments"}).get(
 
67
  return {
68
  "insights": {
69
  "likeCount": None,
70
+ "commentCount": int(comments.replace(",", "")),
71
  "shareCount": None,
72
+ "reactionCount": int(reactions.replace(",", "")),
73
  "reactions": [],
74
  },
75
  "description": desc,