Skip to content

Commit

Permalink
Merge ilkecan:fix-cookiejar-set_all
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanlensky committed Oct 20, 2024
1 parent 77ca75e commit 9bb5d15
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions zendriver/core/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,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 @@ -746,14 +745,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 @@ -764,7 +755,7 @@ async def load(self, file: PathLike = ".session.dat", pattern: str = ".*"):
cookie.value,
)
break
await connection.send(cdp.storage.set_cookies(included_cookies))
await self.set_all(included_cookies)

async def clear(self):
"""
Expand All @@ -783,7 +774,6 @@ async def clear(self):
break
else:
connection = self._browser.connection
await connection.send(cdp.storage.get_cookies())
await connection.send(cdp.storage.clear_cookies())


Expand Down

0 comments on commit 9bb5d15

Please sign in to comment.