V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
kaiger
V2EX  ›  Python

关于 Scrapy 请求的 header 自动转换为 bytes 导致请求失败的问题。

  •  
  •   kaiger · Aug 29, 2022 · 1968 views
    This topic created in 1341 days ago, the information mentioned may be changed or developed.

    为什么 scrapy 请求的 header 会转换为 bytes 类型,这很难受。

    同一个 header , 用 requests 模块请求就能请求成功,用 scrapy 就失败。

    有什么办法能避免这种情况吗?

    Supplement 1  ·  Aug 29, 2022
    抱歉抱歉,请求失败不是 bytes header 的锅,另有原因。

    header 转换为 bytes 在请求的时候好像被转换回来了,并没有影响。
    xiaoqiao24
        1
    xiaoqiao24  
       Aug 29, 2022   ❤️ 1
    2 条路
    1.middleware 里面处理
    2.改底层
    Nostalgia
        2
    Nostalgia  
       Aug 29, 2022 via iPhone
    从来没意识到有这个问题……应该是对我爬的网站没啥影响。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2141 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 00:48 · PVG 08:48 · LAX 17:48 · JFK 20:48
    ♥ Do have faith in what you're doing.