MCPcopy Create free account
hub / github.com/apify/crawlee-python / _from_playwright

Method _from_playwright

src/crawlee/sessions/_cookies.py:174–186  ·  view source on GitHub ↗

Convert Playwright cookie to internal format.

(self, cookie_dict: PlaywrightCookieParam)

Source from the content-addressed store, hash-verified

172 return PlaywrightCookieParam(**result)
173
174 def _from_playwright(self, cookie_dict: PlaywrightCookieParam) -> CookieParam:
175 """Convert Playwright cookie to internal format."""
176 result: dict = dict(cookie_dict)
177
178 if 'httpOnly' in result:
179 result['http_only'] = result.pop('httpOnly')
180 if 'sameSite' in result:
181 result['same_site'] = result.pop('sameSite')
182 if 'expires' in result:
183 expires = int(result['expires'])
184 result['expires'] = None if expires == -1 else expires
185
186 return CookieParam(name=result.pop('name', ''), value=result.pop('value', ''), **result)
187
188 def get_cookies_as_dicts(self) -> list[CookieParam]:
189 """Convert cookies to a list with `CookieParam` dicts."""

Callers 2

test_convert_dict_formatFunction · 0.80

Calls 1

CookieParamClass · 0.85

Tested by 1

test_convert_dict_formatFunction · 0.64