如何通过Scrapy登录cookie到Selenium? [英] How to pass Scrapy login cookies to Selenium?

查看:807
本文介绍了如何通过Scrapy登录cookie到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.

另请参阅:

  • scrapy authentication login with cookies
  • Access session cookie in scrapy spiders

这篇关于如何通过Scrapy登录cookie到Selenium?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆