Get instagram followers

后端 未结 5 614
醉梦人生
醉梦人生 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:31

    Most of the content is dynamically generated with JS. That's the reason you're getting empty results.

    But, the followers count is present in the page source. Only thing is, it is not directly available in the form you want. You can see it here:

    
    

    If you want to scrape the followers count without regex, you can use this:

    >>> followers = soup.find('meta', {'name': 'description'})['content']
    >>> followers
    '407.4k Followers, 27 Following, 2,740 Posts - See Instagram photos and videos from Lazada Malaysia (@lazada_my)'
    >>> followers_count = followers.split('Followers')[0]
    >>> followers_count
    '407.4k '
    

提交回复
热议问题