而不是2016-11-25' /' 2016-11-27'如果我只想要过去24小时的结果,我该怎么办?我也只想要一些特定账户的推文,那么我应该在api搜索中写什么呢?
for tweet in tweepy.Cursor(api.search,
q='giveaway',
since='2016-11-25',
until='2016-11-27',
).items(10):
print('Tweet by: @' + tweet.user.screen_name)
答案 0 :(得分:1)
使用datetime模块
from datetime import datetime, timedelta
now = datetime.today().now()
prev=now-timedelta(days=1)
now=now.strftime("%Y-%m-%d")
prev=prev.strftime("%Y-%m-%d")
for tweet in tweepy.Cursor(api.search,
q='giveaway',
since=prev
until=now
).items(10):
print('Tweet by: @' + tweet.user.screen_name)