Skip to content

Commit

Permalink
feat: add try except to catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentLvr committed Mar 13, 2024
1 parent d2f5f15 commit 9b4fac7
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,23 @@
" pagination_token = None\n",
" while True:\n",
" if \"/in/\" in linkedin_url:\n",
" # Requests from LinkedIn API\n",
" tmp_df = linkedin.connect(li_at, JSESSIONID).profile.get_posts_feed(\n",
" linkedin_url,\n",
" pagination_token=pagination_token,\n",
" limit=1,\n",
" sleep=False\n",
" )\n",
" title = tmp_df.loc[0, \"TITLE\"]\n",
" pagination_token = tmp_df.loc[0, \"PAGINATION_TOKEN\"]\n",
" published_date = tmp_df.loc[0, \"PUBLISHED_DATE\"]\n",
" post_url = tmp_df.loc[0, \"POST_URL\"]\n",
" # Check if published date > limit\n",
" datetime_obj = datetime.strptime(published_date, \"%Y-%m-%d %H:%M:%S%z\").date()\n",
" try:\n",
" # Requests from LinkedIn API\n",
" tmp_df = linkedin.connect(li_at, JSESSIONID).profile.get_posts_feed(\n",
" linkedin_url,\n",
" pagination_token=pagination_token,\n",
" limit=1,\n",
" sleep=False\n",
" )\n",
" title = tmp_df.loc[0, \"TITLE\"]\n",
" pagination_token = tmp_df.loc[0, \"PAGINATION_TOKEN\"]\n",
" published_date = tmp_df.loc[0, \"PUBLISHED_DATE\"]\n",
" post_url = tmp_df.loc[0, \"POST_URL\"]\n",
" # Check if published date > limit\n",
" datetime_obj = datetime.strptime(published_date, \"%Y-%m-%d %H:%M:%S%z\").date()\n",
" except Exception as e:\n",
" print(e)\n",
" break\n",
" elif \"/company/\" in linkedin_url:\n",
" try:\n",
" # Requests from LinkedIn API\n",
Expand All @@ -246,6 +250,7 @@
" datetime_obj = datetime.strptime(published_date, \"%Y-%m-%d %H:%M:%S\").date()\n",
" except Exception as e:\n",
" print(e)\n",
" break\n",
" start += 1\n",
" if limit > datetime_obj:\n",
" break\n",
Expand Down

0 comments on commit 9b4fac7

Please sign in to comment.