Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

instascrape.exceptions.exceptions.InstagramLoginRedirectError: Instagram is redirecting you to the login page instead of the page you are trying to scrape. This could be occuring because you made too many requests too quickly or are not logged into Instagram on your machine. Try passing a valid session ID to the scrape method as a cookie to bypass the login requirement #140

Open
monajalal opened this issue Aug 2, 2021 · 2 comments

Comments

@monajalal
Copy link

Thanks a lot for the great API. Do you know how I can fix this error?

(insta) [jalal@goku insta-scrape]$ python test.py
/scratch3/venv/insta/lib/python3.8/site-packages/instascrape/core/_static_scraper.py:134: MissingCookiesWarning: Request header does not contain cookies! It's recommended you pass at least a valid sessionid otherwise Instagram will likely redirect you to their login page.
  warnings.warn(
Traceback (most recent call last):
  File "test.py", line 9, in <module>
    google_post.scrape()
  File "/scratch3/venv/insta/lib/python3.8/site-packages/instascrape/scrapers/post.py", line 73, in scrape
    return_instance = super().scrape(
  File "/scratch3/venv/insta/lib/python3.8/site-packages/instascrape/core/_static_scraper.py", line 144, in scrape
    return_data = self._get_json_from_source(self.source, headers=headers, session=session)
  File "/scratch3/venv/insta/lib/python3.8/site-packages/instascrape/core/_static_scraper.py", line 265, in _get_json_from_source
    self._validate_scrape(json_dict)
  File "/scratch3/venv/insta/lib/python3.8/site-packages/instascrape/core/_static_scraper.py", line 301, in _validate_scrape
    raise InstagramLoginRedirectError
instascrape.exceptions.exceptions.InstagramLoginRedirectError: Instagram is redirecting you to the login page instead of the page you are trying to scrape. This could be occuring because you made too many requests too quickly or are not logged into Instagram on your machine. Try passing a valid session ID to the scrape method as a cookie to bypass the login requirement
(insta) [jalal@goku insta-scrape]$ cat test.py 
from instascrape import * 

google = Profile('https://www.instagram.com/tresorbutik/')
google_post = Post('https://www.instagram.com/p/CSCNBuljxLv/')
google_hashtag = Hashtag('https://www.instagram.com/explore/tags/fashion/')

# Scrape their respective data 
google.scrape()
google_post.scrape()
google_hashtag.scrape()

print(google.followers)
print(google_post['hashtags'])
print(google_hashtag.amount_of_posts)
@code1dot
Copy link

code1dot commented Nov 5, 2021

You should get your login sessionid cookie from instagram (Using a cookie editor of some sort) and then add it to the headers when you scrape your data:

headers = {
  'cookie': 'sessionid=YOUR_SESSIONID_HERE'
}
google = Profile('https://www.instagram.com/tresorbutik/')
google.scrape(headers=headers)

@kareemrasheed89
Copy link

You should get your login sessionid cookie from instagram (Using a cookie editor of some sort) and then add it to the headers when you scrape your data:

headers = {
  'cookie': 'sessionid=YOUR_SESSIONID_HERE'
}
google = Profile('https://www.instagram.com/tresorbutik/')
google.scrape(headers=headers)

This is still not working for me. but still trying

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants