几条推文后,使用推文ID使用tweepy查找推文停止-用户暂停错误

时间:2018-11-18 16:47:11

标签: python twitter tweepy

我有一个带有推文ID的数据集,我想使用Tweepy查找这些推文并将其保存在一个csvfile中。

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.'}]

1 个答案:

答案 0 :(得分:0)

该错误表示写了您要搜索的推文的用户已被暂停,而不是您已被暂停。它是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访问此信息。没有解决方法。