1

我想从 Instagram 不同的公共和私人帐户中抓取数据。但是当我运行以下代码时。

from instagramy import Instagram


# Connecting the profile
user = Instagram("ihtishamKhattak")

# printing the basic details like
# followers, following, bio
print(user.is_verified())
print(user.popularity())
print(user.get_biography())

# return list of dicts
posts = user.get_posts_details()

print('\n\nLikes', 'Comments')
for post in posts:
    likes = post["likes"]
    comments = post["comment"]
    print(likes,comments)

导入错误

4

2 回答 2

1

您可以查看instagramypypi页面

没有 Instagram python 模块。还要确保您没有脚本调用instagramy.py

于 2021-12-31T10:04:41.667 回答
0

将您的脚本更改为

from instagramy import InstagramUser


# Connecting the profile
user = InstagramUser("ihtishamKhattak")

请注意,如果您不提供会话 ID,这可能仅适用于少数请求。

于 2021-12-31T10:13:03.053 回答