Skip to content

Commit 927356b

Browse files
committed
Merge pull request looly#3 from liuwons/master
将Requests的结果由图片转为文本
2 parents b34e118 + 5781113 commit 927356b

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

400/401.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ requests是一个用于在程序中进行http协议下的get和post请求的库
2323
#get请求
2424

2525
>>> r = requests.get("http://www.itdiffer.com")
26-
26+
2727
得到一个请求的实例,然后:
2828

2929
>>> r.cookies
@@ -39,10 +39,10 @@ requests是一个用于在程序中进行http协议下的get和post请求的库
3939

4040
>>> r.headers
4141
{'x-powered-by': 'PHP/5.3.3', 'transfer-encoding': 'chunked', 'set-cookie': 'PHPSESSID=buqj70k7f9rrg51emsvatveda2; path=/', 'expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'keep-alive': 'timeout=15, max=500', 'server': 'Apache/2.2.15 (CentOS)', 'connection': 'Keep-Alive', 'pragma': 'no-cache', 'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'date': 'Mon, 10 Nov 2014 01:39:03 GMT', 'content-type': 'text/html; charset=UTF-8', 'x-pingback': 'http://www.1world0x00.com/index.php/action/xmlrpc'}
42-
42+
4343
>>> r.encoding
4444
'UTF-8'
45-
45+
4646
>>> r.status_code
4747
200
4848

@@ -83,11 +83,49 @@ requests发送post请求,通常你会想要发送一些编码为表单的数
8383

8484
r没有加data的请求,看看效果:
8585

86-
![](http://wxpictures.qiniudn.com/requets-post1.jpg)
86+
```json
87+
{
88+
"args": {},
89+
"data": "",
90+
"files": {},
91+
"form": {},
92+
"headers": {
93+
"Accept": "*/*",
94+
"Accept-Encoding": "gzip, deflate",
95+
"Content-Length": "0",
96+
"Host": "httpbin.org",
97+
"User-Agent": "python-requests/2.4.3 CPython/2.7.8 Windows/7"
98+
},
99+
"json": null,
100+
"origin": "58.246.118.137",
101+
"url": "http://httpbin.org/post"
102+
}
103+
```
87104

88105
r1是加了data的请求,看效果:
89106

90-
![](http://wxpictures.qiniudn.com/requets-post2.jpg)
107+
```json
108+
{
109+
"args": {},
110+
"data": "",
111+
"files": {},
112+
"form": {
113+
"key1": "value1",
114+
"key2": "value2"
115+
},
116+
"headers": {
117+
"Accept": "*/*",
118+
"Accept-Encoding": "gzip, deflate",
119+
"Content-Length": "23",
120+
"Content-Type": "application/x-www-form-urlencoded",
121+
"Host": "httpbin.org",
122+
"User-Agent": "python-requests/2.4.3 CPython/2.7.8 Windows/7"
123+
},
124+
"json": null,
125+
"origin": "58.246.118.139",
126+
"url": "http://httpbin.org/post"
127+
}
128+
```
91129

92130
多了form项。喵。
93131

0 commit comments

Comments
 (0)