python - Instagram scraping - Unable to get redirected by requests -


what i'm trying achieve obtain instagram username user id. i'm trying without instagram api, since app not approved. found out can done, @ least in browser, going follow page redirects url containing username.

lets use instagram id 184846987 example

by going url https://www.instagram.com/web/friendships/184846987/follow/ redirected page https://www.instagram.com/tsrod_/ contains username , can extracted. note user need logged in, in order work.

so i'm trying achieve using python's requests library. think have cookies needed able this. here snippet.

    response = request_session.get(follow_url, allow_redirects=true)     print(response.url) 

this, however, not redirect me anywhere. code outputs same url requested. doing wrong? in advance!

you can try this

follow_url="what_ever_you_put" cookie={"sessionid":"your_session_id"} resp=requests.get(follow_url, cookies=cookie , allow_redirects = true) print(resp.url) 

that it


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -