Get instagram followers

后端 未结 5 619
醉梦人生
醉梦人生 2020-12-19 23:58

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.         


        
5条回答
  •  清酒与你
    2020-12-20 00:30

    soup.find('head', attrs={'class':'count'}) searches for something that looks like , which doesn't exist anywhere in the HTML. The data you're after is contained in the # ^^^ # JSON page_json = script.text.split(' = ', 1)[1].rstrip(';')

    Parse it and everything you need is contained in the object:

    import json
    
    data = json.loads(page_json)
    follower_count = data['entry_data']['ProfilePage'][0]['user']['followed_by']['count']
    

提交回复
热议问题