Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User agent mismatch, changed many useragents but to no avail, still the same error. #2218

Open
F04C opened this issue Mar 18, 2024 · 5 comments
Labels
bug Bug

Comments

@F04C
Copy link

F04C commented Mar 18, 2024

this didn't occur last time i used instaloader, now it needs for me to use --login

HTTP redirect from https://i.instagram.com/api/v1/users/web_profile_info/?username="" to https://i.instagram.com/accounts/login/?next=/api/v1/users/web_profile_info/
An error occurred: Redirected to login page. Use --login.

@F04C F04C added the bug Bug label Mar 18, 2024
@estatistics
Copy link

estatistics commented Mar 19, 2024

to import cookies from browser: python3 /615_import_firefox_session.py -c /mnt/tmp/firefox/default_profile/cookies.sqlite

to download
instaloader --login=USER --user-agent "Mozilla/5.0 (X11; Linux x86_64; ......................." --abort-on=302,400,401,429,403 --stories --tagged --highlights PROFILE/

Better to have also open instagram, and be a "real" profile (activity, likes, comments etc).

You may use trickle to limit download rate.

@Manwithpants812
Copy link

Manwithpants812 commented Apr 20, 2024

Why isn't Instaloader using the User Agent from the browser it got the cookies from? I've verified on Windows that in every instance (--login, --load-cookies, --cookiefile / Firefox or Chrome) Instaloader uses a Linux User Agent, this:

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

An User Agent mismatch from the browser it was logged in from to the one used by Instaloader seems like the most easy thing for Instagram to detect that there's something weird going on. This should be looked at, unless there's a specific tried strategy that I'm not aware of.

@F04C
Copy link
Author

F04C commented Apr 24, 2024

I modified the useragent manually on my code to

'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0.0' -> the downloading now works.

instead of the the default

def default_user_agent() -> str: return ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ' '(KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36') - > used in the instaloadercontext.py

I think it would be best to have useragent checker during the process of downloading and change to a new useragent to avoid this error in the future.

@F04C
Copy link
Author

F04C commented Apr 24, 2024

to import cookies from browser: python3 /615_import_firefox_session.py -c /mnt/tmp/firefox/default_profile/cookies.sqlite

to download instaloader --login=USER --user-agent "Mozilla/5.0 (X11; Linux x86_64; ......................." --abort-on=302,400,401,429,403 --stories --tagged --highlights PROFILE/

Better to have also open instagram, and be a "real" profile (activity, likes, comments etc).

You may use trickle to limit download rate.

this doesn't solve the underlying issue that some of the users prefer not to use their login credentials. Instaloader, as-is, works without logging in. Something is going on since sometimes the downloading works, and sometimes it requires for me to use --login.

@Manwithpants812
Copy link

Manwithpants812 commented Apr 26, 2024

to import cookies from browser: python3 /615_import_firefox_session.py -c /mnt/tmp/firefox/default_profile/cookies.sqlite
to download instaloader --login=USER --user-agent "Mozilla/5.0 (X11; Linux x86_64; ......................." --abort-on=302,400,401,429,403 --stories --tagged --highlights PROFILE/
Better to have also open instagram, and be a "real" profile (activity, likes, comments etc).
You may use trickle to limit download rate.

this doesn't solve the underlying issue that some of the users prefer not to use their login credentials. Instaloader, as-is, works without logging in. Something is going on since sometimes the downloading works, and sometimes it requires for me to use --login.

Can't say about your specific case but in general, Facebook/Instagram are very "IP aware". If you're using a residential IP, you're likely safe. If you're using a VPN used by thousands, you're not. They also likely have further restrictions to what you can do when not logged in, so at a certain point they ask you to login.

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

No branches or pull requests

3 participants