Skip to content

Commit

Permalink
fix: get conversations not working for more than 20
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentLvr committed Mar 14, 2024
1 parent 094531e commit 3d71575
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions naas_drivers/tools/linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,9 @@ def get_conversations(
count = limit
if limit > limit_max:
limit = limit_max

params = {"count": count}
while True:
params = {"count": count}
req_url = f"{LINKEDIN_API}/message/getConversations?{urllib.parse.urlencode(params, safe='(),')}"
res = requests.post(req_url, json=self.cookies, headers=HEADERS)
res.raise_for_status()
Expand All @@ -1036,8 +1037,8 @@ def get_conversations(
if len(df) >= limit:
break
# Set created before params
last_message_sent_at = tmp_df["LAST_MESSAGE_SENT_AT"].iloc[0]
created_before = datetime.strptime(last_message_sent_at, DATETIME_FORMAT)
last_message_sent_at = tmp_df["LAST_MESSAGE_SENT_AT"].iloc[-1]
created_before = int(datetime.strptime(last_message_sent_at, DATETIME_FORMAT).strftime("%s") + "000")
params["created_before"] = created_before
if sleep:
time.sleep(TIME_SLEEP)
Expand Down

0 comments on commit 3d71575

Please sign in to comment.