Tweepy游标在两个循环内出现问题,试图增加游标中的值

时间:2019-05-12 19:57:48

标签: python tweepy

我正在尝试在Tweepy常规游标的循环之外运行循环。
详细说明:
我从某个用户那里获得了一定数量的推文,我想跳到另一个用户,一次又一次地做同样的事情。

for count in range(4):
   for status in tweepy.Cursor(api.user_timeline, screen_name=user_list[count], tweet_mode="extended").items(number_of_tweets):
      print(status.id)
   print(status.user.name)

它返回一个错误。

Twitter用户列表如下: user_list = ["@alefrotabrasil", "@jeanwyllys_real‏", "@rafinhabastos", "@paradasp", "@TodosFeministas",`

当我将“ user_list [count]”的变量“ count”更改为数字时,该程序运行良好,可以在外部循环运行的同时获得相同的用户信息。
感谢您的帮助。

这是我遇到的错误:

Traceback (most recent call last):
  File "/home/marcelo/PycharmProjects/Twitter1.2/main.py", line 40, in <module>
    for status in tweepy.Cursor(api.user_timeline, screen_name=user_list[count], tweet_mode="extended").items(number_of_tweets):
  File "/usr/local/lib/python3.7/dist-packages/tweepy/cursor.py", line 49, in __next__
    return self.next()
  File "/usr/local/lib/python3.7/dist-packages/tweepy/cursor.py", line 197, in next
    self.current_page = self.page_iterator.next()
  File "/usr/local/lib/python3.7/dist-packages/tweepy/cursor.py", line 108, in next
    data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kargs)
  File "/usr/local/lib/python3.7/dist-packages/tweepy/binder.py", line 250, in _call
    return method.execute()
  File "/usr/local/lib/python3.7/dist-packages/tweepy/binder.py", line 234, in execute
    raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: Twitter error response: status code = 404

0 个答案:

没有答案