当 运行 这个 tweepy 脚本时,我会收到多少请求和每个请求的推文?

How many requests and tweets per request do I get when running this tweepy script?

我正在尝试根据标签名称检索推文并将它们保存为 JSON 文件以供以后分析。我阅读了推特的文档,但不幸的是我不明白。下面是一段代码。

for tweet in tweepy.Cursor(api.search,q=hashtag_name,count=100,wait_on_rate_limit=True ,wait_on_rate_limit_notify= True).items():
    # Create and save the data on the Desktop as a JSON file.
    f= open(os.path.expanduser("~/Desktop")+'/'+time_str+'/'+'%d_%s_tweets.json'%(file_name_counter,hashtag_category), 'a',encoding="utf-8") 
    f.write(json.dumps(tweet._json))
    f.write("\n")
    file_name_counter += 1

我想知道:

How many requests does this code sends per minute?

此代码循环不休眠,因此它会发送尽可能多的请求。由于速率限制,这是个坏主意。

How much tweets does 1 request retrieves?

你的参数是count=100所以答案是100。

Where exactly does this code send a request to twitter server?

转到https://api.twitter.com/1.1/search/tweets.json

Eventually I want to save each request's tweets on a JSON file

其实是这样做的

请阅读:https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html