今天使用BeautiSoup遇到乱码,在网上找到解决方案,特地记录一下
1、先查看网页的编码格式
一般是在网页的开头
2、将requests的结果修改为相对应的编码格式
res1=requests.get(url,headers=head)
res1.encoding='utf-8'
soup1=BeautifulSoup(res1.text,'lxml')
一般是在网页的开头
res1=requests.get(url,headers=head)
res1.encoding='utf-8'
soup1=BeautifulSoup(res1.text,'lxml')