Skip to content
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

Fix cookiejar set all #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions nodriver/core/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ async def set_all(self, cookies: List[cdp.network.CookieParam]):
break
else:
connection = self._browser.connection
cookies = await connection.send(cdp.storage.get_cookies())
await connection.send(cdp.storage.set_cookies(cookies))

async def save(self, file: PathLike = ".session.dat", pattern: str = ".*"):
Expand Down Expand Up @@ -744,14 +743,6 @@ async def load(self, file: PathLike = ".session.dat", pattern: str = ".*"):
save_path = pathlib.Path(file).resolve()
cookies = pickle.load(save_path.open("r+b"))
included_cookies = []
connection = None
for tab in self._browser.tabs:
if tab.closed:
continue
connection = tab
break
else:
connection = self._browser.connection
for cookie in cookies:
for match in pattern.finditer(str(cookie.__dict__)):
included_cookies.append(cookie)
Expand All @@ -762,7 +753,7 @@ async def load(self, file: PathLike = ".session.dat", pattern: str = ".*"):
cookie.value,
)
break
await connection.send(cdp.storage.set_cookies(included_cookies))
self.set_all(included_cookies)

async def clear(self):
"""
Expand Down