How to web scrape users who liked an instagram picture?

风流意气都作罢 提交于 2019-12-06 07:15:20

If it is not a requirement for you to use Beautifulsoup and parse the HTML response yourself, there is Instaloader, a Python library that allows to access Instagram very easily. After doing pip install instaloader to install it, you can do

import instaloader
L = instaloader.Instaloader()
Post = instaloader.Post.from_shortcode(L.context, 'Bziq7f2C-jM')

Then, Post.get_likes() returns an Iterator over the Profiles that have liked the Post, so to print all the usernames, you can do

for like in Post.get_likes():
    print(like.username)

Besides being an easy solution, Instaloader has also the advantage that it handles rate limiting automatically, and that it supports handling login and accessing posts of private profiles.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!