正在删除点赞数最高的instagram帐户的图片



我正在尝试编写一个脚本,从instagram帐户获取数据,特别是下载点赞数最高的帐户的图片。这样做可能吗?我怎么能对一些现有的库做这样的事情?我不是数据抓取方面的专家,这个项目的一部分是让我学习如何做到这一点

有一个Instaloader,一个Python库,使用它只需几行即可轻松完成:

from instaloader import Instaloader, Profile
PROFILE = "..."   # Insert profile name here
L = Instaloader()
# Obtain profile
profile = Profile.from_username(L.context, PROFILE)
# Get all posts and sort them by their number of likes
posts_sorted_by_likes = sorted(profile.get_posts(), key=lambda post: post.likes, reverse=True)
# Download the post with the most likes
L.download_post(posts_sorted_by_likes[0], PROFILE)

最新更新