-5

How can I write a code to implement the function of limiting http request number per second with python?

For example, I specify 100 request number for the python script, then the script will just send 100 url to the server per second.

I searched out this link: Limiting number of HTTP requests per second on Python. However, I did not get it from this page.

Community
  • 1
  • 1
eason
  • 69
  • 1
  • 5

1 Answers1

0

If you only want one request at the same time you could just do it with time.sleep(1).

import requests
import time

r = requests.get("http://www.google.com")
print(r)
time.sleep(1)
r = requests.get("http://www.stackoverflow.com")
print(r)
time.sleep(1)
Kordi
  • 2,405
  • 1
  • 14
  • 13