Get list of users who commented or liked post on instagram with Python(获取在Instagram上使用Python发表评论或点赞的用户列表)
问题描述
我在Python中发现了 我翻遍了所有的文档,但我找不到答案。这是文档:https://instaloader.github.io/as-module.html 这是我拥有的代码:Instaloader
lib,它允许擦除Instagram配置文件。这很好,但是我找不到在Instagram上评论或点赞帖子的用户列表。
import instaloader
L = instaloader.Instaloader() #nalazenje stvari sa instagrama
profile = instaloader.Profile.from_username(L.context, 'jlo') #daj mi pratioce od datog user-a
print(profile.get_posts())
for post in profile.get_posts():
post_likes = post.get_likes()
post_comments = post.get_comments()
print(post_likes) # post_likes object
print(post_comments) # # post_comments object
# post_likes.name post_likes.username post_likes.user DOES NOT WORK
# post_comments.name post_comments.username post_comments.user DOES NOT WORK
推荐答案
get_likes()
生成一个生成器来迭代喜欢帖子的帐户的配置文件。get_comments()
会生成一个命名元组,其中owner
是发帖者的帐户。因此,代码的有效实现如下所示:
import instaloader
L = instaloader.Instaloader() #nalazenje stvari sa instagrama
profile = instaloader.Profile.from_username(L.context, 'jlo') #daj mi pratioce od datog user-a
print(profile.get_posts())
for post in profile.get_posts():
post_likes = post.get_likes()
post_comments = post.get_comments()
print(post_likes) # post_likes object
print(post_comments) # # post_comments object
# Iterate over all likes of the post. A Profile instance of each likee is yielded.
for likee in post_likes:
print(likee.username)
# Iterate over all comments of the post.
# Each comment is represented by a PostComment namedtuple with fields
# text (string), created_at (datetime), id (int), owner (Profile)
# and answers (~typing.Iterator[PostCommentAnswer]) if available.
for comment in post_comments:
print(comment.owner.username)
这篇关于获取在Instagram上使用Python发表评论或点赞的用户列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取在Instagram上使用Python发表评论或点赞的用户列表


- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 沿轴计算直方图 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01