【发布时间】:2018-10-30 02:18:23
【问题描述】:
我正在尝试编写一个从 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)
【讨论】: