diff --git a/curl_cffi/requests/cookies.py b/curl_cffi/requests/cookies.py index 5559a173..5c6842e9 100644 --- a/curl_cffi/requests/cookies.py +++ b/curl_cffi/requests/cookies.py @@ -290,6 +290,20 @@ def delete( for cookie in remove: self.jar.clear(cookie.domain, cookie.path, cookie.name) + def get_dict(self, domain: Optional[str] = None, path: Optional[str] = None) -> dict: + """Takes as an argument an optional domain and path and returns a plain + old Python dict of name-value pairs of cookies that meet the + requirements. + + """ + dictionary = {} + for cookie in self.jar: + if (domain is None or cookie.domain == domain) and ( + path is None or cookie.path == path + ): + dictionary[cookie.name] = cookie.value + return dictionary + def clear( self, domain: typing.Optional[str] = None, path: typing.Optional[str] = None ) -> None: