4 HTTP协议及Requests库方法
"""HTTP及requests库方法""" import requests # requests库head()方法:得到头部信息 r = requests.head("http://httpbin.org/get") print(r.headers) print(r.text) # 空 # requests库post()方法:向表单增加信息 payload = {‘key1‘: ‘value1‘, ‘key2‘:‘value2‘} r = requests.post("http://httpbin.org/post", data = payload) print(r.text) # requests库post()方法:向data增加信息 r = requests.post("http://httpbin.org/post", data = "ABC") print(r.text) # requests库put()方法:覆盖原有数据 payload = {‘key1‘: ‘value1‘, ‘key2‘:‘value2‘} r = requests.put("http://httpbin.org/put", data = payload) print(r.text)
相关推荐
Guanjs0 2020-11-09
wmsjlihuan 2020-09-15
shishengsoft 2020-09-15
poplpsure 2020-08-17
CyborgLin 2020-08-15
Richardxx 2020-07-26
sunnyhappy0 2020-07-26
knightwatch 2020-07-19
wcqwcq 2020-07-04
chichichi0 2020-06-16
YAruli 2020-06-13
JF0 2020-06-13
84423067 2020-06-12
心丨悦 2020-06-11
stoneechogx 2020-06-04
litterfrog 2020-05-30
today0 2020-05-26
beibeijia 2020-05-16