关于测试:0407-接口请求构造

32次阅读

共计 395 个字符,预计需要花费 1 分钟才能阅读完成。

get query 申请

params_query = {
"key1": "value1",
"key2": "value2"
}

r = requests.get(url, params=params_query)

form 申请

params_form = {
"key1": "value1",
"key2": "value2"
}

r = requests.post(url, data=params_form)

文件上传

files = {"file": open("file_path", "rb")
}

r = requests.post(url, files=files)

header

headers = {"user-agent": "agent"}

r = requests.get(url, headers=headers)

cookie

cookies = {"cookies": "value"}

r = requests.get(url, cookies=cookies)

正文完
 0