GET请求
- 无参数
requests.get('http://xxxxxxx/')
- 有参数
payload = {'key1':'value','key2':'value'}
requests.get('http://xxxxxxx/',params=payload)
POST请求
- 表单提交
payload = {'key1':'value','key2':'value'}
requests.post('http://xxxxxxx/',data=payload)
- x-www-form-urlencoded形式
增加headers配置 Content-Type:application/x-www-form-urlencoded
data传入字典
payload ={'key1':'value','key2':'value'}
requests.post(url, data=payload,headers={'Content-Type':'application/x-www-form-urlencoded'})
- raw(文本)提交
json形式
payload ={'some':'data'}
requests.post(url, json=payload,headers={'Content-Type':'application/json'})
或
payload ={'some':'data'}
requests.post(url, data=json.dumps(payload),headers={'Content-Type':'application/json'})
无论何种方式提交 ,一定要记得加上请求头