question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, i’m receiving always the error : “InstagramLoginRedirectError”, so i want to login. Taking as example your code :

Instantiate the scraper objects

google = Profile('https://www.instagram.com/google/')

Scrape their respective data

google.scrape()

How can i login with username and password ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
tarob0bacommented, Jan 25, 2021

Based on what I’ve seen in the source, I believe (~95%) that you should pass your Instagram session id to the scrape method as indicated by the exception, but you should confirm with @chris-greening, since I don’t have an account to test this.

from instascrape import *

session_id = '' # Your session ID - http://valvepress.com/how-to-get-instagram-session-cookie/

google = Profile('https://www.instagram.com/google/')

headers = {"user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36 Edg/87.0.664.57",
           "cookie": f"sessionid={session_id};"}

google.scrape(headers=headers)

print(google.followers)
1reaction
drctodaycommented, Sep 23, 2021

@beckettnormington nailed it exactly, thank you so much!

@Matteoo98, Instagram has been making it increasingly harder to scrape data from their platform so for the most part, you will have to pass a valid session ID as a cookie (as shown above in Beckett’s sample code).

Unfortunately, instascrape itself doesn’t provide login capabilities as of right now because it runs the risk of getting an account flagged as suspicious but you can manually find your session ID by following these steps.

Hope this helps!

Hi Chris,

I am pretty sure I am passing the Session Id (from Google Chrome – Inspect – Application – Instagram – Session Id, and my Instagram account is logged in). However, I still receive a message indicates that I need to pass an active session id as cookie.

“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”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Accounts: Sign in
Forgot email? CAPTCHA image of text used to distinguish humans from robots.
Read more >
Login
Login · Open the notification on your phone · Enter the challenge code below into the Handy Key Mobile app to generate a...
Read more >
Microsoft 365: Login
Collaborate for free with online versions of Microsoft Word, PowerPoint, Excel, and OneNote. Save documents, workbooks, and presentations online, ...
Read more >
Log into Facebook
Log into Facebook to start sharing and connecting with your friends, family, and people you know.
Read more >
Login.gov: The public's one account for government.
Use one account and password for secure, private access to participating government agencies.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found