GeezerVison is showing github.com — 将Requests的结果由图片转为文本 · ForLiveForLife/python-basic@5781113
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: 400/401.md +43-5Lines changed: 43 additions & 5 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,7 @@ requests是一个用于在程序中进行http协议下的get和post请求的库 | 23 | 23 | #get请求 | 24 | 24 |
| 25 | 25 | >>> r = requests.get("http://www.itdiffer.com") | 26 | | - | | 26 | + | 27 | 27 | 得到一个请求的实例,然后: | 28 | 28 |
| 29 | 29 | >>> r.cookies | @@ -39,10 +39,10 @@ requests是一个用于在程序中进行http协议下的get和post请求的库 | 39 | 39 |
| 40 | 40 | >>> r.headers | 41 | 41 | {'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 | + | 43 | 43 | >>> r.encoding | 44 | 44 | 'UTF-8' | 45 | | - | | 45 | + | 46 | 46 | >>> r.status_code | 47 | 47 | 200 | 48 | 48 |
| @@ -83,11 +83,49 @@ requests发送post请求,通常你会想要发送一些编码为表单的数 | 83 | 83 |
| 84 | 84 | r没有加data的请求,看看效果: | 85 | 85 |
| 86 | | - | | 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 | +``` | 87 | 104 |
| 88 | 105 | r1是加了data的请求,看效果: | 89 | 106 |
| 90 | | - | | 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 | +``` | 91 | 129 |
| 92 | 130 | 多了form项。喵。 | 93 | 131 |
| |
|