Skip to content

Commit 599999a

Browse files
ipeirotisCopilot
andauthored
Update scholarly/_proxy_generator.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 460a28b commit 599999a

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

scholarly/_proxy_generator.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,15 @@ def _handle_captcha2(self, url):
445445
self.logger.info(f"Solved captcha in less than {cur} seconds.")
446446

447447
for cookie in self._get_webdriver().get_cookies():
448-
cookie.pop("httpOnly", None)
449-
cookie.pop("expiry", None)
450-
cookie.pop("sameSite", None)
451-
cookie.pop("secure", None) # httpx Cookies.set() does not accept 'secure'
452-
self._session.cookies.set(**cookie)
448+
# Construct a new dict containing only the kwargs supported by httpx.Cookies.set().
449+
cookie_kwargs = {}
450+
for key in ("name", "value", "domain", "path"):
451+
if key in cookie:
452+
cookie_kwargs[key] = cookie[key]
453+
# Map Selenium's 'expiry' field to httpx's 'expires' parameter, if present.
454+
if "expiry" in cookie:
455+
cookie_kwargs["expires"] = cookie["expiry"]
456+
self._session.cookies.set(**cookie_kwargs)
453457

454458
return self._session
455459

0 commit comments

Comments
 (0)