instaloader icon indicating copy to clipboard operation
instaloader copied to clipboard

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

Open drlshx opened this issue 1 year ago • 5 comments

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.

drlshx avatar Mar 18 '24 20:03 drlshx

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.

estatistics avatar Mar 19 '24 08:03 estatistics

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.

Manwithpants812 avatar Apr 20 '24 14:04 Manwithpants812

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.

drlshx avatar Apr 24 '24 20:04 drlshx

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.

drlshx avatar Apr 24 '24 21:04 drlshx

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.

Manwithpants812 avatar Apr 26 '24 00:04 Manwithpants812