Scrapy:在调用之间保存 cookie [英] Scrapy: saving cookies between invocations
本文介绍了Scrapy:在调用之间保存 cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在抓取爬虫的调用之间保留 cookie?目的 - 该站点需要登录,然后通过 cookie 维护会话.我宁愿重复使用会话而不是每次都重新登录.
解决方案
请参考关于 cookie 的文档.
或者,您可以使用自己管理的 cookie 发送 Request
对象(您可以从 Response
对象的头部读取 cookie).
Is there a way to preserve cookies between invocations of a scrapy crawler? The purpose - the site requires log in, and then maintains the session via cookies. I'd rather reuse the session than re-login every time.
解决方案
Please refer to the docs about cookies.
Alternatively you can send Request
objects with cookies managed by yourself (you can read cookies from Response
objects' head).
About Request and Response objects
这篇关于Scrapy:在调用之间保存 cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文