I am trying to figure out how to output the location of the twitter user only if they have it displayed. How would I go about doing that? Right now I have this:
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
import time
import json
from HTMLParser import HTMLParser
ckey = ''
csecret = ''
atoken = ''
asecret = ''
class listener(StreamListener):
def on_status(self, status):
print status.text
if status.coordinates:
print 'coords:', status.coordinates
if status.place:
print 'place:', status.place.full_name
return True
on_event = on_status
def on_error(self, status):
print status
auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Stream(auth, listener())
twitterStream.filter(track=["twerk"])
Edit: it's giving an error for the last line of code. How could I filter the word "twerk" or "miley"
So it's currently outputting a tweet if the tweet consists of the words twerk or miley, but I would like to get the coordinates of that tweet only if they have it displayed. I thought it would be something like tweet = data.coordinates, but that is not working. Any ideas?