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")