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="免费电影下载,电'
python爬虫自动解决字符编码问题
最新推荐文章于 2023-03-27 19:28:14 发布