import chardet
import requests
url = 'http://www.100253.com/'
d1 = requests.get(url)
codesty = chardet.detect(d1.content)
a = d1.content.decode(codesty['encoding'])
a.encode('utf-8')
python爬取网页乱码解决方案
最新推荐文章于 2024-01-25 11:56:25 发布
本文介绍了一种使用Python的chardet库检测网页编码的方法,并通过requests库获取网页内容,然后根据检测到的编码进行内容解码及重新编码为UTF-8的过程。此过程对于处理不同编码的网页数据尤为重要。
7947

被折叠的 条评论
为什么被折叠?



