I'm using Tweepy to stream tweets. I'm trying to filter out retweeted content using the retweeted_status identifier in the json file. I want the for loop to execute after the empty return statement of the if statement on the line before it, but it doesn't seem to work- nothing gets printed out. The script seems to stop after the if statement:
class StreamListener(tweepy.StreamListener):
def on_status(self, status):
#these variable split out the data from the outputted json
text = status.text
name = status.user.screen_name
id_str = status.id_str
#This if argument ensures that if there is retweeted status then None is returned
if hasattr (status, 'retweeted_status'):
return
for url in status.entities['urls']:
print (text, name, (url['expanded_url']), file=open("results.txt", "a"))
Aucun commentaire:
Enregistrer un commentaire