python爬蟲自動解決字元編碼問題
阿新 • • 發佈:2018-12-11
In [34]: import requests
...:
...: response = requests.get('http://www.dytt8.net/index.htm')
...: print(response.text[200:300])
...:
-Type content="text/html; charset=gb2312">
<title>μ?ó°ììì?_?a·?μ?ó°_??à×μ?ó°????</title>
<META con
In [35]: response.apparent_encoding
Out[35 ]: 'GB2312'
In [36]: response.encoding
Out[36]: 'ISO-8859-1'
In [37]: response.encoding = response.apparent_encoding
In [38]: response.text[200:300]
Out[38]: '-Type content="text/html; charset=gb2312">\r\n<title>電影天堂_免費電影_迅雷電影下載</title>\r\n<META content="免費電影下載,電'