我正在尝试运行一个简单的脚本,它将传送实时推文。多次尝试过滤出转发失败。我仍然在我的流中获得手动转发(文本“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