I'm very much new to python. I need a code which will fetch the tweets and the places from where it is tagged,or geo-tagged tweets.
I Have code which will export the tweets the csv file based o the hash tag given, I want another column added, with specifies from where it is tweeted.
Please help me on this.
The code is as follows,
import tweepy
import csv
import pandas as pd
####input your credentials here
consumer_key = ''
consumer_secret = ''
access_token = '-'
access_token_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth,wait_on_rate_limit=True)
csvFile = open('mydoc.csv', 'a')
#Use csv Writer
csvWriter = csv.writer(csvFile)
for tweet in tweepy.Cursor(api.search,q="#iPhoneX",count=100,
lang="en",
since="2017-01-01").items():
print (tweet.created_at, tweet.text)
csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])
I'm in very much in need of it.Please help !!!