gpt4 book ai didi

python - Tweepy 没有返回给定数量的推文

转载 作者:行者123 更新时间:2023-12-04 15:10:10 27 4
gpt4 key购买 nike

我有以下代码

api = tweepy.API(auth,wait_on_rate_limit=True)
for tweet in tweepy.Cursor(api.search,
tweet_mode="extended",
q=query + " exclude:retweets").items(11000):
hashtags = "#" + " #".join([hashtag['text'] for hashtag in tweet.entities.get('hashtags')])
print(i)

if tweet.place:
tweet_place = tweet.place.full_name + ', ' + tweet.place.country_code
else:
tweet_place = "Not Geo-tagged"
i += 1

csvWriter.writerow([tweet.id, tweet.full_text.encode('utf-8'), tweet.created_at, tweet.lang, tweet.retweet_count, tweet.favorite_count, tweet_place, tweet.user.id, tweet.user.screen_name, tweet.user.followers_count, tweet.user.friends_count, tweet.user.created_at, tweet.user.favourites_count, tweet.user.statuses_count, tweet.user.lang, tweet.user.verified, tweet.user.location])

我试图通过特定的搜索查询获取 11000 条推文,但一段时间后它抛出以下错误:

Traceback (most recent call last):
.............
ConnectionResetError: [Errno 54] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
.............
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
.............
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
.............
tweepy.error.TweepError: Failed to send request: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))

早些时候它发生在大约 2500 条推文上,但在更改查询时它开始发生在大约 5000 条推文上。知道哪里出了问题以及我该如何解决吗?

最佳答案

这很可能是因为您已经超过了一次/每 15 分钟可以拉取的推文的允许数量

检查 here获取更多信息。

关于python - Tweepy 没有返回给定数量的推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65351131/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com