如何通过Scrapy登录cookie到Selenium? [英] How to pass Scrapy login cookies to Selenium?
问题描述
我需要Selenium的javascript工作。
I need Selenium for javascript work.
首先我使用Scrapy FormRequest
登录,然后我需要打开 response.url
与Selenium。
First I login using Scrapy FormRequest
and then I need to open the response.url
with Selenium.
问题是Selenium没有cookie,所以打开登录
The problem is that Selenium does not have the cookies so It opens the login page.
有人知道如何将cookies从scrapy传递给selenium?
Does anyone know how can I pass the cookies from scrapy to selenium?
推荐答案
由于您尚未提供任何您到目前为止撰写的程式码,因此我只会转介您。
Since you haven't provided any code you've written so far, I'll just refer you.
为了从Scrapy请参阅 scrapy.http.cookies.CookieJar
和 extract_cookie
方法(请参阅 Scrapy - 如何管理Cookie /会话)。
In order to get cookies from Scrapy take a look at scrapy.http.cookies.CookieJar
and extract_cookie
method (see Scrapy - how to manage cookies/sessions).
为了设置selenium驱动程序的cookie,请参阅 add_cookie 方法。
In order to set cookies for selenium driver, see add_cookie method.
另请参阅:
- 使用Cookie进行scrapy验证登录
- < a href =http://stackoverflow.com/questions/8708346/access-session-cookie-in-scrapy-spiders>在scrapy蜘蛛中访问会话Cookie
- scrapy authentication login with cookies
- Access session cookie in scrapy spiders
这篇关于如何通过Scrapy登录cookie到Selenium?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!