我想准备一个python脚本,一次发送1000个用户的发布请求,并根据api调用全部更新它们。我已经有了curl。
pyhton脚本
import sys
import uuid
import json
import requests
import hashlib
import time
headers1 = {'X-Tenant-Key':'test1','X-Tenant-Name':'test','Content-
Type': 'application/json','Cache-Control':'no-cache'}
count=0
for line in open("/home/pallav/postpaid_restart.txt"):
columns = line.rstrip('\n').split('\t')
if(len(columns)==1):
uid=columns[0]
try:
url2='http://something..../postpaid/restart/'+uid
count=count+1
r3= requests.post(url2, headers=headers1)
print count,uid,r3.status_code
time.sleep(0.05)
if count%500==0:
time.sleep(3)
if count%1000==0:
time.sleep(3)
except:
time.sleep(0.03)
continue
这是卷曲
curl -X POST \
'http://something..../kyc/postpaid/restart?user_id=<USERID>' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'X-TENANT-KEY: test1' \
-H 'X-TENANT-NAME: test'