如何在python上的特定日期从用户那里提取推文? [英] How do I pull tweets from a user for specific dates on python?
本文介绍了如何在python上的特定日期从用户那里提取推文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从路透社 (@reuters) 推特帐户下载 2019 年 11 月的推文.
I am trying to download tweets from the Reuters (@reuters) twitter account for the month of November 2019.
我在 python 上使用 tweepy,这是我的代码:
I am using tweepy on python and this is my code:
pip install tweepy
import tweepy as tw
#Keys
consumer_key = "..."
consumer_secret = "..."
access_token = "..."
access_token_secret = "..."
# Login
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tw.API(auth, wait_on_rate_limit=True)
#Get user's tweets
tweets = tw.Cursor(api.user_timeline,
id="reuters",
lang="en",
since="2019-11-01",
until="2019-11-30").items()
all_tweets = [tweet.text for tweet in tweets]
all_tweets[:100]
直到"参数似乎不起作用,因为我的代码提取的推文包括最新的推文.
The "until" parameter does not seem to be working because the tweets that my code pulls include latest tweets.
推荐答案
我有答案.如果没有付费,您就无法做到这一点.
I have the answer. You cannot do this without going premium.
这篇关于如何在python上的特定日期从用户那里提取推文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文