I want to parse a website\'s followers count with BeautifulSoup. This is what I have so far:
username_extract = \'lazada_my\'
url = \'https://www.instagram.
You have to look for the scripts, Then look for the 'window._sharedData' exits in it. If exits then perform the regular expression operation.
import re
username_extract = 'lazada_my'
url = 'https://www.instagram.com/'+ username_extract
r = requests.get(url)
soup = BeautifulSoup(r.content,'lxml')
s = re.compile(r'"followed_by":{"count":\d*}')
for i in soup.find_all('script'):
if 'window._sharedData' in str(i):
print s.search(str(i.contents)).group()
Result,
"followed_by":{"count":407426}