推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
foxyier
V2EX  ›  Python

最近抓取一个网站,编码格式无法解决, 求助帖

  •  1
     
  •   foxyier · Oct 31, 2018 · 3012 views
    This topic created in 2930 days ago, the information mentioned may be changed or developed.
    通过查看网页源码, 网站编码格式为 utf-8, 可是通过 utf-8 解码提示 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte, 通过设置 ignore 参数, 成功得到了一堆乱码。 网站链接在此: http://www.bw30.com/tszt/huodong/09/wpsj/index.htm, 坐等各位大佬协助~
    8 replies  •  2018-10-31 15:32:39 +08:00
    zealot0630
    zealot0630
    Oct 31, 2018
    1
    bom 了解一下
    binux
    binux
    Oct 31, 2018
    2
    GB2312
    foxyier
    foxyier
    OP
    Oct 31, 2018
    3
    @binux gb2312 和 gbk 都会报 UnicodeDecodeError: 'gb2312' codec can't decode byte 0xff in position 0: illegal multibyte sequence
    ysc3839
    ysc3839
    Oct 31, 2018 via Android
    4
    估计是 UTF-8 BOM 吧?
    Sylv
    Sylv
    Oct 31, 2018 via iPhone
    5
    上代码,要不然我们只能瞎猜。
    fzzff
    fzzff
    Oct 31, 2018
    6
    chardet 试试
    XIVN1987
    XIVN1987
    Oct 31, 2018
    7
    同意楼上,百度“ UTF-8 BOM python ”试试
    foxyier
    foxyier
    OP
    Oct 31, 2018
    8
    @fzzff 多谢, 检测出来了, 编码格式是 utf-16
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1632 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 08:09 · PVG 16:09 · LAX 00:09 · JFK 03:09
    ♥ Do have faith in what you're doing.