ITPub博客

首页 > 应用开发 > Python > Python爬虫中文乱码的问题(设置Accept-Encoding参数)

Python爬虫中文乱码的问题(设置Accept-Encoding参数)

Python 作者:iherb中文 时间:2024-05-31 07:42:00 0 删除 编辑

初识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去掉,就可以实现。

转载于:https://www.itbulu.com/accept-encoding.html

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31380193/viewspace-3017279/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2016-08-01

  • 博文量
    15
  • 访问量
    23702