1、get方法:
payload={ "name":"lhys.notNeed" } r=requests.get('http://zj.gcjs.zdvictory.com/unionpro/unionpro/ignorecheck/sysPara/findByName',params=payload) print(r.text)
post方法:
1、application/x-www-form-urlencoded格式import requests datas = {"param1": "Detector", "param2": "cnblogs"} r = requests.post("http://httpbin.org/post", data=datas) print(r.text) print(r.status_code)2、 application/json格式
import json import requests headers = {'Content-Type': 'application/json'} datas = json.dumps({"param1": "Detector", "param2": "cnblogs"}) r = requests.post("http://httpbin.org/post", data=datas, headers=headers) print(r.text)3、text/xml数据格式
请求数据这样:
examples.getStateName 41
参考Python实现
import requests headers = {"Content-Type": "text/xml"} datas = """4、multipart/form-data数据格式(含文件上传)""" r = requests.post("http://httpbin.org/post", data=datas, headers=headers) print(r.text) examples.getStateName 41
import requests files = {"file": open("C:/Users/Administrator/Desktop/test.txt", "rb")} r = requests.post("http://httpbin.org/post", files=files) print(r.text)
5、headerS构造
headers={ "Content-Type":"application/json", "charset":"UTF-8"} r=requests.get(url,params=payload,headers=headers)
6、cookies构造
7、xml请求
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)