有关在特定时间范围内使用tweepy进行特定用户的关键字搜索的问题

时间:2019-04-11 22:41:03

标签: python pycharm keyword tweepy username

我希望我的输出仅是某个用户在某个时间范围内使用关键字发出的推文。这可能吗?如果没有,是否有办法在特定的时间范围内做特定的用户?

import tweepy
import csv

consumer_key = 'WIexDSZwi0ZRqkRLBD0gGyxx0'
consumer_secret = 
'dVobHvCkRFv34XIRRxsnYYdChk7k8hGiPVxpIl19JR6Bxywym4'
access_token = '1115338304394756096-P9mLVi7uAjwDwldVhk5CIMoajNb38d'
access_token_secret = 
'ONToUl6KiH3jWvjBtOVGHkORdJDEhAT9HrMmGiixSAhY6'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)



# Open/Create a file to append data
csvFile = open('tweets.csv', 'a')
#Use csv Writer
csvWriter = csv.writer(csvFile)


for tweet in 
tweepy.Cursor(api.user_timeline,id="nytimes",max_id=2018-12- 
22).items():
print tweet.created_at, tweet.text
csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])

0 个答案:

没有答案