Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookiejars exposed #6218

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions scrapy/downloadermiddlewares/cookies.py
Expand Up @@ -16,7 +16,7 @@

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
Expand Down Expand Up @@ -51,7 +51,13 @@
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)

Check warning on line 56 in scrapy/downloadermiddlewares/cookies.py

View check run for this annotation

Codecov / codecov/patch

scrapy/downloadermiddlewares/cookies.py#L56

Added line #L56 was not covered by tests
return o

def spider_opened(self, spider: Spider) -> None:
spider.jars = self.jars

Check warning on line 60 in scrapy/downloadermiddlewares/cookies.py

View check run for this annotation

Codecov / codecov/patch

scrapy/downloadermiddlewares/cookies.py#L60

Added line #L60 was not covered by tests
Gallaecio marked this conversation as resolved.
Show resolved Hide resolved

def _process_cookies(
self, cookies: Iterable[Cookie], *, jar: CookieJar, request: Request
Expand Down