python - Tweepy 按日期获取推文
问题描述
我想在日期之间获取某个主题的推文。这在 tweepy 中可能吗?(或任何其他推特 API?)
我可以通过使用 ID 让它为 user_timeline 工作,但是当我将它更改为使用 api.search 时,程序基本上只是继续运行而没有任何输出
def getTweets(username):
tweets = []
tmpTweets = api.user_timeline(username, tweet_mode = 'extended', include_rts=True)
for tweet in tmpTweets:
if tweet.created_at < endDate and tweet.created_at > startDate:
tweets.append(tweet)
while (tmpTweets[-1].created_at > startDate):
tmpTweets = api.user_timeline(username, max_id = tmpTweets[-1].id,tweet_mode = 'extended')
for tweet in tmpTweets:
if tweet.created_at < endDate and tweet.created_at > startDate:
tweets.append(tweet)
return tweets
tl;dr: python 中有没有一种方法可以根据关键字搜索在两个日期之间获取推文?
解决方案
推荐阅读
- java - 重启按钮抛出异常,我不知道如何修复它
- kubernetes - 引导 etcd 集群 - 这意味着什么?
- android - 如何在另一个应用程序模块中使用库模块的 .aar 中的 .so 文件?
- bash - 从 awk 返回中提取数值
- linux - 从三列文件中删除重复记录
- python - Pandas to_excel 不写换行符
- android - 云功能更新获取父节点和子节点的内容
- python - Django rest框架未经身份验证的用户在测试中获取请求错误
- bootstrap-4 - 让品牌和汉堡在 xs 视图中左右对齐而不是中心
- javascript - 从外部 SVG 调用全局定义的 JavaScript 函数