V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2021-06-01 16:55:20 +08:00 · 1089 次点击
    这是一个创建于 1032 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我有一个 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
       2021-06-07 09:05:24 +08:00
    有没有人哇..........
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2810 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:50 · PVG 22:50 · LAX 07:50 · JFK 10:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.