簡體   English   中英

如何忽略我已在Tweepy中轉發過的推文?

[英]How do I ignore tweets that I have already retweeted in Tweepy?

我試圖忽略我自己已經轉發的推文,但我真的不知道如何指定,我知道'如果不是tweet.retweeted:'忽略轉推但我不知道如何忽略我已轉發的推文在我的Twitter api搜索中。

for tweet in tweepy.Cursor(api.search,
                   q='- Play Free Spin http://csgoroll.com/freespin',
                   since='2017-12-20',
                   screen_name='CSGORoll'
                   ).items(10):
            if not tweet.retweeted:
                    tweet.retweet()
                    print("CSGORoll, Working...")
                    return

如果您的問題是腳本沒有繼續,您可以使用tryexcept

try:
    tweet.retweet()
except tweepy.TweepError as e:
    print(e)

在這種情況下,您將打印以下消息,並將繼續轉發與您的搜索匹配的下一條推文。

Output: [{u'message': u'You have already retweeted this Tweet.', u'code': 327}]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM