How to pass Scrapy login cookies to Selenium?

2019-04-02 04:26发布

I need Selenium for javascript work.

First I login using Scrapy FormRequest and then I need to open the response.url with Selenium.

The problem is that Selenium does not have the cookies so It opens the login page.

Does anyone know how can I pass the cookies from scrapy to selenium?

1条回答
Animai°情兽
2楼-- · 2019-04-02 05:02

Since you haven't provided any code you've written so far, I'll just refer you.

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).

In order to set cookies for selenium driver, see add_cookie method.

Also see:

查看更多
登录 后发表回答