Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
273 views
in Technique[技术] by (71.8m points)

python - Twitter API-请求延迟问题-随机延迟? -Python请求(Twitter API - Request Delay Issue - Random Delay? - Python Requests)

Once I send my requests they comeback instantly but there seems to be an issue where I get a random delay in between requests out of no where!?

(一旦我发送了请求,它们就会立即恢复,但是似乎出现了一个问题,我在两次请求之间随机地延迟了一个请求!)

I really do require there to be no delay, looking for all the help I can get!

(我确实要求没有延迟,寻找我能得到的所有帮助!)

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
  ask by Far Jat translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...