我正在嘗試運行一個簡單的腳本,它將傳送實時推文。多次嘗試過濾出轉發失敗。我仍然在我的流中獲得手動轉發(文本「RT @」)。 我試過其他方法,包括link和link。忽略轉推Twitter推文時的轉推
由於我學習,我的代碼是非常類似於以下內容:link
我能做些什麼,以忽略銳推?
這裏是我的代碼片段:
class StreamListener(tweepy.StreamListener):
def on_status(self, status):
if (status.retweeted) and ('RT @' not in status.text):
return
description = status.user.description
loc = status.user.location
text = status.text
coords = status.coordinates
geo = status.geo
name = status.user.screen_name
user_created = status.user.created_at
followers = status.user.followers_count
id_str = status.id_str
created = status.created_at
retweets = status.retweet_count
bg_color = status.user.profile_background_color
# Initialize TextBlob class on text of each tweet
# To get sentiment score from each class
blob = TextBlob(text)
sent = blob.sentiment
'status'對象是什麼樣的? – ninesalt
你的邏輯似乎有點困惑 - '(status.retweeted)和('RT @'不在status.text中)'只會返回「官方」轉推。也許你應該使用'(status.retweeted)或('RT @'status.text)'排除「官方」和「手動」轉發 – asongtoruin