微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

带有流的 Tweepy 挂起跟随标签

如何解决带有流的 Tweepy 挂起跟随标签

我正在尝试运行 Tweepy StreamListener 以关注用户在 Twitter 上的推文。

当我使用 track 关键字时它有效,但当我添加 follow='userid' 时它挂起。我做错了什么吗?

stream_listener = StreamListener()
auth = OAuthHandler("","")
auth.set_access_token("","")
stream = Stream(auth=auth,listener=stream_listener)
#stream.filter(follow="")
api = tweepy.API(auth)
screen_name = "ThetaWarrior"
user = api.get_user(screen_name)
api = tweepy.API(auth,wait_on_rate_limit=True)
print("User details:")
print(user.name)
print(user.description)
print(user.location)
print(user.id_str)
stream.filter(follow="98**************")

解决方法

follow 参数需要是用户 ID 列表,而不是字符串,例如:
stream.filter(follow=["98**************"])
假设 "98**************" 是实际用户 ID。

请参阅 the Streaming with Tweepy section of the documentation 以获取 Tweepy v3.10 或 the documentation for Stream.filter 以获取主分支上 Tweepy 的最新开发版本,即将发布为 v4.0。另见the documentation for the POST statuses/filter endpoint

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。