我正在尝试使用以下代码获取有关推文的数据。但是,我也想获得位置和原始推文,而不是转发。请提出建议。
import tweepy
import csv
import pandas as pd
####input your credentials here
consumer_key= 'XXXX'
consumer_secret= 'XXXX'
access_token = 'XXXX'
access_token_secret = 'XXXX'
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)
# 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="#RamMandir",count=100,
lang="en",
since="2017-04-03").items():
print (tweet.created_at, tweet.text)
csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])