代码如图,爬的是bilibili的搜索页面,但是print出来的数据全是这种乱码,已知这个网页的确是用的utf-8
import requests
word = input('>')
payload = {'keyword':word}
r = requests.get('http://search.bilibili.com/all', params=payload)
print(r.text.encode('utf-8'))
迷茫2017-04-18 10:17:32
r = requests.get(url, proxies=proxies)
r.encoding = r.apparent_encoding
print r.text
This is a relatively simple method that is suitable for most encodings