Requests library not working on Instagram analysis tool on Google Collab

Asked

Viewed 22 times

0

I am developing a very simple tool to simply collect the number of followers of Instagram accounts. I am doing by Google Collab since the company I work imposes several security restrictions when it comes to the use of some Pyhton terminal on the laptop (you will understand...)

Basically, I’m using this code:

import requests

user = "taylorswift"
#a escolha da conta a ser analisada é totalmente aleatória

url = 'https://www.instagram.com/' + user
r = requests.get(url).text

start = '"edge_followed_by":{"count":'
end = '},"followed_by_viewer"'

print(r[r.find(start)+len(start):r.rfind(end)])

is a very simple code to only parse the html code and return the value between the strings mentioned above.

The following message is being returned:

inserir a descrição da imagem aqui

What strikes me the most is the answer "Page not Found"... I don’t know if I’m wrong or if the google collab platform doesn’t allow me to perform this kind of function.

If you have any insight I’d appreciate it...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.