首页 > 解决方案 > 在几条推文后停止使用推文 id 查找 tweepy 推文 - 用户暂停错误

问题描述

我有一个带有推文 ID 的数据集,我想使用 Tweepy 查找推文并将它们保存在 csv 文件中。

auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

api = tweepy.API(auth, wait_on_rate_limit=True)

def get_tweet_text(tweet_id):
    tweet = api.get_status(tweet_id)
    return tweet.text

with open('NAACL_SRW_2016_cleaned.csv', 'a') as csvfile_clean:  
    writer = csv.writer(csvfile_clean, delimiter=';')
    writer.writerow(['ID', 'Form of Hate Speech', 'Tweet'])                 

    with open('NAACL_SRW_2016.csv') as csvfile:
        csv_reader: object = csv.reader(csvfile, delimiter=',')
        for row in csv_reader:
            id_of_tweet = (row[0])
            hate = (row[1])
            tweet = get_tweet_text(id_of_tweet)
            print(tweet)

            writer = csv.writer(csvfile_clean, delimiter=';')
            writer.writerow([id_of_tweet, hate, tweet])

该代码工作正常,但在几条推文后它停止了,我收到下面的错误消息。但是,我并没有被停职——我的账户上没有收到任何关于这方面的消息,我仍然可以流式传输推文。我尝试了不同的 IP 并重新生成了密钥,但我总是收到错误消息。有人经历过类似的事情吗?如果您有任何关于我可以尝试使其工作的提示,我将非常感激。

So Drasko just said he was impressed the girls cooked half a chicken.. 
They cooked a whole one  #MKR
Drasko they didn't cook half a bird you idiot #mkr
Hopefully someone cooks Drasko in the next ep of #MKR
of course you were born in serbia...you're as fucked as A Serbian Film
These girls are the equivalent of the irritating Asian girls #MKR  
Lost the plot - where's the big Texan with the elephant sized steaks

tweepy.error.TweepError: [{'code': 63, 'message': 'User has been 
suspended.'}]

标签: pythontwittertweepy

解决方案


该错误表明撰写您正在搜索的推文的用户已被暂停,而不是您拥有。它是 tweepy api 返回的错误代码 63 的值,如下所示https://developer.twitter.com/en/docs/basics/response-codes.html

twitter 响应代码表指出代码 63 表示The user account has been suspended and the information cannot be retrieved.

您将无法使用 api 访问此信息。没有解决办法。


推荐阅读