Twitter API - 请求延迟问题 - 随机延迟? - Python Requests

2024-05-17 10:19:03 发布

您现在位置:Python中文网/ 问答频道 /正文

一旦我发送了我的请求,它们会立即返回,但似乎有一个问题,我会在两个请求之间得到一个随机的延迟!?我真的需要有没有延误,寻找所有的帮助,我可以得到

import requests 
from requests_oauthlib import OAuth1
import datetime

url = 'https://api.twitter.com/1.1/account/verify_credentials.json'
auth = OAuth1(consumer_key1, consumer_secret1, access_token_key1, access_token_secret1)
requests.get(url, auth=auth)

while True:
    print(datetime.datetime.now())
    r = requests.get('https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=stackoverflow&count=1', auth=auth)
    print(datetime.datetime.now())```

2019-12-01 04:05:05.723679
2019-12-01 04:05:05.723679
2019-12-01 04:05:05.966036
2019-12-01 04:05:05.966036
2019-12-01 04:05:06.172799
2019-12-01 04:05:06.173329
2019-12-01 04:05:06.384113
2019-12-01 04:05:06.384113
2019-12-01 04:05:06.581163
2019-12-01 04:05:06.581163
2019-12-01 04:05:06.814331
2019-12-01 04:05:06.814331
2019-12-01 04:05:07.042689
2019-12-01 04:05:07.042689

Tags: httpsimportcomauthapijsonurldatetime