From ee937446d7d0269f3b85df060487213582533d6a Mon Sep 17 00:00:00 2001 From: Lyonnet Date: Tue, 24 Sep 2024 16:05:14 +0800 Subject: [PATCH] Bump version to 0.7.2, close #389 --- docs/cookies.rst | 19 +++++++++++++++++-- pyproject.toml | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/cookies.rst b/docs/cookies.rst index 9a92afc..c5d41a3 100644 --- a/docs/cookies.rst +++ b/docs/cookies.rst @@ -7,15 +7,18 @@ How to save and load cookies Do not use ``get_dict`` to dump and load cookies. Cookies are more than just plain key-value pairs. +Using pickle: + .. code-block:: python + # example from: https://github.com/encode/httpx/issues/895 import pickle # import httpx from curl_cffi import requests def save_cookies(client): with open("cookies.pk", "wb") as f: - pickle.dump(client.cookies.jar, f) + pickle.dump(client.cookies.jar._cookies, f) def load_cookies(): if not os.path.isfile("cookies.pk"): @@ -24,5 +27,17 @@ key-value pairs. return pickle.load(f) # client = httpx.Client(cookies=load_cookies()) - client = requests.Session(cookies=load_cookies()) + client = requests.Session() + client.get("https://httpbin.org/cookies/set/foo/bar") save_cookies(client) + + client = requests.Session() + client.cookies.jar._cookies.update(load_cookies()) + print(client.cookies.get("foo")) + + +Using mozilla cookie jar: + +See: https://github.com/lexiforest/curl_cffi/issues/381 + +TODO: expose libcurl's native cookies.txt support. diff --git a/pyproject.toml b/pyproject.toml index 7e0afca..db6bea9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,13 @@ [project] name = "curl_cffi" -version = "0.7.1" +version = "0.7.2" authors = [{ name = "Lyonnet", email = "infinitesheldon@gmail.com" }] description = "libcurl ffi bindings for Python, with impersonation support." license = { file = "LICENSE" } dependencies = [ "cffi>=1.12.0", "certifi>=2024.2.2", + "typing_extensions", ] readme = "README.md" requires-python = ">=3.8"