-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Improve cookie handling #5463
Open
farsene
wants to merge
22
commits into
scrapy:master
Choose a base branch
from
OrestisKan:improve-cookie-handling
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Improve cookie handling #5463
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…er. Add metho to the spider to interact with the cookie
Add persistence of cookies when spider is closed
…ng as wrong method was being called. complex test not done yet - issues when sending multiple cookies as request header
This reverts commit b60cb1e.
Codecov Report
@@ Coverage Diff @@
## master #5463 +/- ##
==========================================
- Coverage 88.75% 88.48% -0.28%
==========================================
Files 163 165 +2
Lines 10666 10786 +120
Branches 1818 1836 +18
==========================================
+ Hits 9467 9544 +77
- Misses 923 961 +38
- Partials 276 281 +5
|
Gallaecio
reviewed
May 20, 2022
Comment on lines
+191
to
+216
.. method:: set_cookie_jar(cj) | ||
|
||
Initiate the spider's cookie jar from an existing one | ||
|
||
.. method:: add_cookie(cookie) | ||
|
||
Add cookie to the spider's cookiejar | ||
|
||
.. method:: get_cookies(name, names, return_type) | ||
|
||
:param name: name of cookie to fetch, default = None | ||
:type name: str | ||
|
||
:param names: names of cookies to fetch, default = None | ||
:type names: List[str] | ||
|
||
:param return_type: return format if multiple cookies, default = list, options are list, dict | ||
:type return_type: object | ||
|
||
Get cookie by name or the cookies whose name is in names. | ||
If names is used, then the return value will be in the format of the return_type | ||
|
||
.. method:: clear_cookies() | ||
|
||
Erase spider's cookiejar | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big API change, which should probably be discussed in #1878 before working on an implementation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding storage of cookies in local file that allows cross-spider access of cookies and providing interface method for the spiders to retrieve the cookies. Spiders automatically load the saved cookies when they are opened and write the new cookies to the file when they are closed such that another new opened spider can reuse the existing cookies.
Part of #5431