Skip to content

Commit 8694710

Browse files
authored
Update Python爬虫之Requests库.md
1 parent dee90c5 commit 8694710

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

studynotes/Python爬虫之Requests库.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ r = requests.get('https://github.com/timeline.json')
2525
r.encoding='utf-8'
2626
r.text
2727
u'[{"repository":{"open_issues":0,"url":"https://github.com/...</code></pre>
28+
29+
### 网页乱码问题
30+
31+
# 查看网页编码
32+
print(res.apparent_encoding)
33+
# 设置编码
34+
res.encoding = 'GB2312'
35+
2836
### 二进制响应内容(r.content)
2937
可以通过字节<strong>r.content</strong>的方式访问请求响应体,对于非文本(比如图片)请求:
3038
<pre><code>

0 commit comments

Comments
 (0)