mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
继续cookies相关,未完成
This commit is contained in:
parent
c62b28d50e
commit
7a8558befc
@ -726,14 +726,14 @@ def _session_options_to_dict(options: Union[dict, SessionOptions, None]) -> Unio
|
||||
|
||||
|
||||
def _cookie_to_dict(cookie: Cookie) -> dict:
|
||||
# cookie_dict = {'name': cookie.name, 'value': str(cookie.value), 'path': cookie.path, 'domain': cookie.domain}
|
||||
|
||||
# if cookie.expires:
|
||||
# cookie_dict['expiry'] = cookie.expires
|
||||
|
||||
# return cookie_dict
|
||||
"""把Cookie对象转为dict格式"""
|
||||
if isinstance(cookie, Cookie):
|
||||
return cookie.__dict__
|
||||
# return cookie.__dict__
|
||||
cookie_dict = {'name': cookie.name, 'value': str(cookie.value), 'path': cookie.path, 'domain': cookie.domain}
|
||||
|
||||
if cookie.expires:
|
||||
cookie_dict['expiry'] = cookie.expires
|
||||
|
||||
elif isinstance(cookie, dict):
|
||||
return cookie
|
||||
else:
|
||||
|
@ -162,7 +162,7 @@ class Drission(object):
|
||||
if isinstance(cookies, (list, tuple, RequestsCookieJar)):
|
||||
cookies = tuple(_cookie_to_dict(cookie) for cookie in cookies)
|
||||
elif isinstance(cookies, str):
|
||||
cookies = tuple(dict([cookie.split("=", 1)]) for cookie in cookies.split("; "))
|
||||
cookies = tuple(dict([cookie.lstrip().split("=", 1)]) for cookie in cookies.split(";"))
|
||||
elif isinstance(cookies, dict):
|
||||
cookies = tuple({'name': cookie, 'value': cookies[cookie]} for cookie in cookies)
|
||||
else:
|
||||
@ -176,10 +176,16 @@ class Drission(object):
|
||||
if set_driver:
|
||||
self.driver.add_cookie(cookie)
|
||||
|
||||
def add_a_cookie(self):
|
||||
def add_a_cookie(self,
|
||||
cookie: str,
|
||||
set_session: bool = False,
|
||||
set_driver: bool = False):
|
||||
pass
|
||||
|
||||
def remove_a_cookie(self):
|
||||
def remove_a_cookie(self,
|
||||
name: str,
|
||||
set_session: bool = False,
|
||||
set_driver: bool = False):
|
||||
pass
|
||||
|
||||
def clear_cookies(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user