Skip to content
Permalink
Browse files

Workaround for issue #488

  • Loading branch information
AlexNik authored and rarcega committed Feb 3, 2020
1 parent f1378a4 commit 9a6fc01393d038523ece9ef193edf2931cbc3d21
Showing with 11 additions and 1 deletion.
  1. +11 −1 instagram_scraper/app.py
@@ -867,7 +867,17 @@ def fetch_highlight_stories(self, user_id):
higlight_stories_ids = [item['node']['id'] for item in
retval['data']['user']['edge_highlight_reels']['edges']]

return self.__fetch_stories(HIGHLIGHT_STORIES_REEL_ID_URL.format('%22%2C%22'.join(str(x) for x in higlight_stories_ids)))
# Workaround for issue https://github.com/rarcega/instagram-scraper/issues/488
# __fetch_stories with count of ids more than 20 some times returns "Bad gateway" error.
# Instagram web site fetches by 3.
ids_chunks = [higlight_stories_ids[i:i + 3] for i in range(0, len(higlight_stories_ids), 3)]

stories = []

for ids_chunk in ids_chunks:
stories.extend(self.__fetch_stories(HIGHLIGHT_STORIES_REEL_ID_URL.format('%22%2C%22'.join(str(x) for x in ids_chunk))))

return stories

return []

0 comments on commit 9a6fc01

Please sign in to comment.
You can’t perform that action at this time.