【问题标题】:Receiving "Stream encountered HTTP error: 409" when using Twitter API. What is causing this error and how can I fix it?使用 Twitter API 时收到“流遇到 HTTP 错误:409”。是什么导致了这个错误,我该如何解决?
【发布时间】:2022-08-03 16:13:20
【问题描述】:
import tweepy
import time

api_key = \"\"
api_secret = \"\"
bearer_token = r\"\"
access_token = \"\"
access_token_secret = \"\"

client = tweepy.Client(bearer_token, api_key, api_secret, access_token, access_token_secret)

auth = tweepy.OAuth1UserHandler(bearer_token, api_key, api_secret, access_token, access_token_secret)
api = tweepy.API(auth)

class MyStream(tweepy.StreamingClient):
  def on_tweet(self, tweet):
    try:
      print(tweet.text)
      client.like(tweet.id)
    except Exception as error:
      print(error)
    
    time.sleep(5)

stream = MyStream(bearer_token=bearer_token)

stream.add_rules(tweepy.StreamRule(\"#Python OR #programming -is:retweet -is:reply\"), dry_run=True)

stream.filter()

真的不确定发生了什么,因为我关注这个 youtube 视频到 T。

https://www.youtube.com/watch?v=tC9GnD0aU2c

  • 您的意思是使用dry_run 参数吗?
  • 您正在初始化 Tweepy apiclient 对象,但随后不使用它们?

标签: python api twitter bots twitterapi-python


【解决方案1】:

您找到解决方案了吗?

【讨论】:

    猜你喜欢
    • 2021-12-30
    • 1970-01-01
    • 2020-04-22
    • 2022-01-07
    • 2011-01-28
    • 1970-01-01
    • 2018-07-13
    • 1970-01-01
    • 2015-06-13
    相关资源
    最近更新 更多