检索少量用户的推文后,Python-Twitter Tweepy 401响应

时间:2018-07-27 16:40:13

标签: python json twitter twitter-oauth tweepy

我正在从用户帐户的关注者那里获取推文,关注者数量约为2k。检索他们之后,我正在抓住他们的推文,它工作正常,但达到一定数量后,它会给出401响应。请看屏幕

consumer_key = ""

consumer_secret =
access_token = "1023510199-"
access_token_secret = ""
screen_name = "@"

    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    api = tweepy.API(auth, wait_on_rate_limit=True)

    alltweets = []
    if(api.verify_credentials):
      print ('We sucessfully logged in')

    users = tweepy.Cursor(api.followers, screen_name=screen_name, count=200).items()
    for u in users:
        for tweet in tweepy.Cursor(api.user_timeline, id = u.id).items():
            print(tweet.text)

回溯(最近通话最近一次):

  

文件“ C:/用户/用户/PycharmProjects/digitalOcean/venv/tresss.py”,   第22行,在       tweepy.Cursor(api.user_timeline,id = u.id).items()中的推文:File   “ C:\ Users \ user \ PycharmProjects \ digitalOcean \ venv \ lib \ site-packages \ tweepy \ cursor.py”,   第49行,下一个       返回self.next()文件“ C:\ Users \ user \ PycharmProjects \ digitalOcean \ venv \ lib \ site-packages \ tweepy \ cursor.py”,   接下来的197行       self.current_page = self.page_iterator.next()文件“ C:\ Users \ user \ PycharmProjects \ digitalOcean \ venv \ lib \ site-packages \ tweepy \ cursor.py”,   接下来的108行       数据= self.method(max_id = self.max_id,parser = RawParser(),* self.args,** self.kargs)文件“ C:\ Users \ user \ PycharmProjects \ digitalOcean \ venv \ lib \ site-packages \ tweepy \ binder.py”,   _call中的第250行       返回method.execute()文件“ C:\ Users \ user \ PycharmProjects \ digitalOcean \ venv \ lib \ site-packages \ tweepy \ binder.py”,   执行中的第234行       引发TweepError(error_msg,resp,api_code = api_error_code)tweepy.error.TweepError:Twitter错误响应:状态码= 401

0 个答案:

没有答案