简体   繁体   English

同一日期当我尝试从 tweepy 获取推文时

[英]Same date When I try get tweets from tweepy

I'm trying to sample tweets with tweepy .我正在尝试使用tweepy对推文进行采样。 I wanted to get, for example, 100 tweets between today Apr 14th and Apr 8. But when I try:例如,我想在今天 4 月 14 日到 4 月 8 日之间获得 100 条推文。但是当我尝试时:

search_words = "#COVID"
date_until = "2020-04-09"

tweets = twepy.Cursor(api.search,
              q=search_words,
              lang="en",
              until = date_until, count = 100,
                     since = date_since).items(100)

I get the following result with tweets from same day:我从同一天的推文中得到以下结果:

2020-04-08 23:58:23    3
2020-04-08 23:59:46    3
2020-04-08 23:58:02    3
2020-04-08 23:59:53    3
2020-04-08 23:58:37    3
2020-04-08 23:58:41    3
2020-04-08 23:59:06    2
2020-04-08 23:59:24    2
2020-04-08 23:59:10    2
2020-04-08 23:59:07    2
2020-04-08 23:58:56    2
2020-04-08 23:59:51    2
2020-04-08 23:58:44    2
2020-04-08 23:58:16    2
2020-04-08 23:59:32    2
2020-04-08 23:57:49    2
2020-04-08 23:57:53    2
2020-04-08 23:58:06    2
2020-04-08 23:59:09    2
2020-04-08 23:59:28    2
2020-04-08 23:58:55    2
2020-04-08 23:59:23    2
2020-04-08 23:59:29    2
2020-04-08 23:57:47    2
2020-04-08 23:59:20    2
2020-04-08 23:59:31    2
2020-04-08 23:57:51    2
2020-04-08 23:58:46    2
2020-04-08 23:58:14    1
2020-04-08 23:59:22    1
2020-04-08 23:58:03    1
2020-04-08 23:58:45    1
2020-04-08 23:59:21    1
2020-04-08 23:59:01    1
2020-04-08 23:58:29    1
2020-04-08 23:59:50    1
2020-04-08 23:59:27    1

Tweets with the same date only differing in some minutes...相同日期的推文仅在几分钟内有所不同...

add the following in your code在您的代码中添加以下内容

wait_on_rate_limit – Whether or not to automatically wait for rate limits to replenish wait_on_rate_limit – 是否自动等待速率限制补充

here is my reference这是我的参考

api = tweepy.API(auth, wait_on_rate_limit=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM