-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement filter_cookies() with domain-matching and path-matching (#8046
) (#7944) --------- Co-authored-by: Sam Bull <[email protected]> Co-authored-by: J. Nick Koston <[email protected]> (cherry picked from commit 54ceb6f) --------- Co-authored-by: xiangxli <[email protected]>
- Loading branch information
1 parent
f47fa39
commit a42ed20
Showing
4 changed files
with
142 additions
and
61 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Implement filter_cookies() with domain-matching and path-matching on the keys, instead of testing every single cookie. | ||
This may break existing cookies that have been saved with `CookieJar.save()`. Cookies can be migrated with this script:: | ||
|
||
import pickle | ||
with file_path.open("rb") as f: | ||
cookies = pickle.load(f) | ||
|
||
morsels = [(name, m) for c in cookies.values() for name, m in c.items()] | ||
cookies.clear() | ||
for name, m in morsels: | ||
cookies[(m["domain"], m["path"].rstrip("/"))][name] = m | ||
|
||
with file_path.open("wb") as f: | ||
pickle.dump(cookies, f, pickle.HIGHEST_PROTOCOL) |
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
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
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