我使用tweepy API搜索推文。我的代码如下所示
num_tweets=10
search = 'tesla stock'
num = 0
for tweet in tweepy.Cursor(api.search,q=search+" -filter:retweets",count=num_tweets,lang="en").items():
num +=1
print(num)
print(tweet.text)
上面的代码不遵守count参数并一直运行,直到达到应用程序的请求速率限制并且误差低于
TweepError:Twitter错误响应:状态代码= 429
我错过了什么吗?
以下是结果的一部分。看到结果计数更多:
1
We have 100 of the Tesla adapters in stock:
2
@erikher101095 also PLEASE BUY TESLA STOCK!!
3
#Tesla $TSLA is the most exciting stock. but it’s not as 24/7 non-stop global exciting as crypto #cryptotrifecta
....
1764
Love Tesla cars & stock, but $7500+ rebates fueled Tesla growth & Musk just kicked taxpayers firmly in the a**!
1765
Tesla's Model 3 could reverse its stock slide #ElonMusk #ElonMusk
1766
Tesla Inc (TSLA) Stock at Risk as Trump Exits Paris Accord
答案 0 :(得分:1)
更新了下面的代码,但它确实有效。
for tweet in tweepy.Cursor(api.search,q=search+" -filter:retweets",lang="en").items(num_tweets):