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

问题描述 投票:0回答:1

我正在尝试使用tweepy采样推文。例如,我想在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)`

我得到:

2020-04-08 23:58:23 32020-04-08 23:59:46 32020-04-08 23:58:02 32020-04-08 23:59:53 32020-04-08 23:58:37 32020-04-08 23:58:41 32020-04-08 23:59:06 22020-04-08 23:59:24 22020-04-08 23:59:10 22020-04-08 23:59:07 22020-04-08 23:58:56 22020-04-08 23:59:51 22020-04-08 23:58:44 22020-04-08 23:58:16 22020-04-08 23:59:32 22020-04-08 23:57:49 22020-04-08 23:57:53 22020-04-08 23:58:06 22020-04-08 23:59:09 22020-04-08 23:59:28 22020-04-08 23:58:55 22020-04-08 23:59:23 22020-04-08 23:59:29 22020-04-08 23:57:47 22020-04-08 23:59:20 22020-04-08 23:59:31 22020-04-08 23:57:51 22020-04-08 23:58:46 22020-04-08 23:58:14 12020-04-08 23:59:22 12020-04-08 23:58:03 12020-04-08 23:58:45 12020-04-08 23:59:21 12020-04-08 23:59:01 12020-04-08 23:58:29 12020-04-08 23:59:50 12020-04-08 23:59:27 12020-04-08 23:59:19 12020-04-08 23:59:40 12020-04-08 23:57:46 12020-04-08 23:58:31 12020-04-08 23:57:54 12020-04-08 23:57:57 12020-04-08 23:57:50 12020-04-08 23:59:43 12020-04-08 23:57:55 12020-04-08 23:59:38 12020-04-08 23:58:26 12020-04-08 23:58:11 12020-04-08 23:59:35 12020-04-08 23:59:45 12020-04-08 23:59:47 12020-04-08 23:58:40 12020-04-08 23:59:59 12020-04-08 23:59:34 12020-04-08 23:59:03 12020-04-08 23:59:00 12020-04-08 23:58:51 12020-04-08 23:58:43 12020-04-08 23:58:25 12020-04-08 23:58:07 12020-04-08 23:58:15 12020-04-08 23:58:47 12020-04-08 23:58:57 12020-04-08 23:59:18 12020-04-08 23:58:48 1

具有相同日期的推文仅在几分钟内有所不同...

有人可以帮忙吗?谢谢

python tweepy sampling tweets
1个回答
0
投票

添加time.sleep()

import time 

tweets = []

for tweet in tweets = twepy.Cursor(api.search, q=search_words, lang="en", until = date_until, count = 100, since = date_since).items(100):
    tweets.append(tweet)
    time.sleep(20)
© www.soinside.com 2019 - 2024. All rights reserved.