Python爬虫中文乱码的问题

常见问题

Python爬虫中文乱码的问题

2024-10-13 14:29


                                            




初识Python爬虫的时候我们可能会去爬一个页面,但是在初始爬虫的时候会看到中文乱码。

headers = {
        "User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36 Edg/89.0.774.54",
        "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-US,q=0.7",
        "Accept-Encoding": "gzip, deflate",
        "Connection": "keep-alive"
}

后来 检查后发现问题在 Accept-Encoding 中,将默认其中的br去掉,就可以实现。

莱卡云服务器,即开即用、价格低至25元/月。 点击了解更


标签:
  • python
  • linux
  • 云服务器