4 HTTP协议及Requests库方法

 1 """HTTP及requests库方法"""
 2 
 3 
 4 import requests
 5 
 6 # requests库head()方法:得到头部信息
 7 r = requests.head("http://httpbin.org/get")
 8 
 9 print(r.headers)
10 print(r.text) #
11 
12 
13 # requests库post()方法:向表单增加信息
14 payload = {key1: value1, key2:value2}
15 r = requests.post("http://httpbin.org/post", data = payload)
16 print(r.text)
17 # requests库post()方法:向data增加信息
18 r = requests.post("http://httpbin.org/post", data = "ABC")
19 print(r.text)
20 
21 # requests库put()方法:覆盖原有数据
22 payload = {key1: value1, key2:value2}
23 r = requests.put("http://httpbin.org/put", data = payload)
24 print(r.text)

4 HTTP协议及Requests库方法

4 HTTP协议及Requests库方法

上一篇:部署一套完整的Kubernetes高可用集群(二进制,最新版v1.18)下


下一篇:cefSharp通过js操控页面,含跨域操控