mirror of https://github.com/scrapy/scrapy.git
cookiejars exposed
This commit is contained in:
parent
6f73dc0e67
commit
fe2979edf3
|
|
@ -16,7 +16,7 @@ from typing import (
|
|||
|
||||
from tldextract import TLDExtract
|
||||
|
||||
from scrapy import Request, Spider
|
||||
from scrapy import Request, Spider, signals
|
||||
from scrapy.crawler import Crawler
|
||||
from scrapy.exceptions import NotConfigured
|
||||
from scrapy.http import Response
|
||||
|
|
@ -51,7 +51,13 @@ class CookiesMiddleware:
|
|||
def from_crawler(cls, crawler: Crawler) -> Self:
|
||||
if not crawler.settings.getbool("COOKIES_ENABLED"):
|
||||
raise NotConfigured
|
||||
return cls(crawler.settings.getbool("COOKIES_DEBUG"))
|
||||
o = cls(crawler.settings.getbool("COOKIES_DEBUG"))
|
||||
if crawler.settings.getbool("COOKIES_EXPOSE_JARS"):
|
||||
crawler.signals.connect(o.spider_opened, signal=signals.spider_opened)
|
||||
return o
|
||||
|
||||
def spider_opened(self, spider: Spider) -> None:
|
||||
spider.jars = self.jars
|
||||
|
||||
def _process_cookies(
|
||||
self, cookies: Iterable[Cookie], *, jar: CookieJar, request: Request
|
||||
|
|
|
|||
Loading…
Reference in New Issue