Python3.x:BeautifulSoup()解析网页内容出现乱码

Python3.x:BeautifulSoup()解析网页内容出现乱码

问题:

start_html = requests.get(all_url, headers=Hostreferer)
BeautifulSoup(start_html.text, "html.parser")

 出现乱码; 

解决方案:

 将BeautifulSoup(start_html.text, "html.parser")替换为BeautifulSoup(start_html.content, "html.parser"),即可;

start_html = requests.get(all_url, headers=Hostreferer)
BeautifulSoup(start_html.content, "html.parser")

 

posted @ 2018-01-14 20:05  整合侠  阅读(402)  评论(0编辑  收藏  举报