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
ZoeYn
V2EX  ›  Python

scrapy 设置 cookie 有的时候会失效是怎么回事?

  •  
  •   ZoeYn · Jun 1, 2021 · 1901 views
    This topic created in 1803 days ago, the information mentioned may be changed or developed.

    我有一个 cookie 池,以集合的形式存在 redis 里。在爬虫的过程中,每一次请求 url 都会从 redis 里拿 cookie 并且带上它访问。大多数是可以设置成功的,但是中间会出现设置失败的情况。找来找去都找不到是啥原因。 附上我设置 cookie 的方式: settings.py

    COOKIES_ENABLED = True
    

    spider.py

    cookies2 = json.loads(self.red.srandmember('red_cookies', 1)[0])
    yield scrapy.Request(url=url, cookies=cookies2, meta=metas, callback=self.parse)
    

    求解,有没有遇到类似情况的前辈啊,实在是困扰我很久啦!

    ZoeYn
        1
    ZoeYn  
    OP
       Jun 7, 2021
    有没有人哇..........
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2988 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 14:50 · PVG 22:50 · LAX 07:50 · JFK 10:50
    ♥ Do have faith in what you're doing.