|import pandas as pd|
|####input your credentials here|
|consumer_key = ''|
|consumer_secret = ''|
|access_token = ''|
|access_token_secret = ''|
|auth = tweepy.OAuthHandler(consumer_key, consumer_secret)|
|api = tweepy.API(auth,wait_on_rate_limit=True)|
|# Open/Create a file to append data|
|csvFile = open('ua.csv', 'a')|
|#Use csv Writer|
|csvWriter = csv.writer(csvFile)|
|for tweet in tweepy.Cursor(api.search,q="#unitedAIRLINES",count=100,|
|print (tweet.created_at, tweet.text)|
How would I go about adding in location(e.g. geo_id or coordinates) and user_id? I've been going through the Tweepy documentation and Twitter API documentation, but can't find any information to add arguments like tweet.text and tweet.created_at.
Update: After some more digging, I managed to find this output of the json file to find which arguments can be called for information: https://gist.github.com/dev-techmoe/ef676cdd03ac47ac503e856282077bf2
So, I learned that I can call geo, place, and coordinates (tweet.geo, tweet.place, tweet.coordinates), but it doesn't appear to do well for historical data. I maybe pulled 3 out of several thousand so far :/
But it's a handy reference for things like tweet.user.id or tweet.user.screen_name!
I'm still looking for a way to determine if the tweet is a retweet (tweets I'd like to remove in my analysis), but besides the tweet.text beginning with "b'RT @" or if it is an advertisement (e.g. 'Buy 3 for 2 promotion' kinda thing). If anyone has any advice on those, I'd be greatly appreciative!