Python_requests实例
Posted tianpin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python_requests实例相关的知识,希望对你有一定的参考价值。
在测试过程中,需要进行团体报名,需要测试报名的最高上限数量,以及分页,若一个个进行报名,很浪费时间和精力,我们想到使用python语言编写代码来实现。
import requests
header =
"authorization": "cbafcba131318a4112f82743c8b08f0b3f655cd1",
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (Khtml, like Gecko) Chrome/70.0.3538.102 Safari/537.36/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"
def apply(name, cardNumber):
applyData =
"pName": name,
"gender": 1,
"country": 344,
"identType": 2,
"identCard": cardNumber,
"birthDate": "1993-06-03",
"phone": "100000000",
"email": "[email protected]",
"bloodType": "A",
"province": "上海市",
"city": "黄浦区",
"Address": "ceshi",
"emergency": "dd",
"emergencyPhone": "15811540163",
"job": 1,
"education": 1,
"income": "5万以内",
"matchEventID": "5192974392788471",
"teamID": 5210251418835258,
"runnerSource": 2
applyUrl = "https://saas-user-gw-test.mararun.com/v1/application/apply"
try:
request = requests.post(url = applyUrl, headers=header,data = applyData)
print("status_code = %s" %request.status_code)
print(request.json())
except Exception as e:
print(e)
for i in range(100,152):
print("i=",i)
name = "testName"+ str(i)
cardNumber = i
apply(name, cardNumber)
print("-----------------")
以上是关于Python_requests实例的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Laravel 8 的 Request 类中访问模型实例?
response和httpresponse。。。request和httprequest的区别