我想获取20000条以上的记录,因此我尝试编写以下python代码并将其完美地工作。但是有点慢每记录需要2-3秒,因此如何加快速度。
import requests
import sys
import time
from tqdm import tqdm
url = "https://www.example.org/web/api/Profile/users"
headers = {
'Content-Type': "application/x-www-form-urlencoded",
'Access-Control-Allow-Origin': "*",
'Accept-Encoding': "gzip, deflate",
'Accept-Language': "en-US",
}
n = (int(sys.argv[1]))
sum = 0
for i in tqdm(range(0,n)):
payload = "user_id={}".format(i+1)
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
sum = sum + i