When I use pyppeteer with cookies, the below exception is raised
File "test.py", line 33, in asyncio.get_event_loop().run_until_complete(main())
File "/usr/local/python3.6/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete return future.result()
File "test.py", line 25, in main await page.setCookie(cookies)
File "/usr/local/python3.6/lib/python3.6/site-packages/pyppeteer/page.py", line 392, in setCookie await self.deleteCookie(*items)
File "/usr/local/python3.6/lib/python3.6/site-packages/pyppeteer/page.py", line 373, in deleteCookie await self._client.send('Network.deleteCookies', item)
File "/usr/local/python3.6/lib/python3.6/site-packages/pyppeteer/connection.py", line 200, in send return await callback
pyppeteer.errors.NetworkError: Protocol Error: Invalid parameters name: string value expected
My code listed:
async def main():
cookies = {'name': "", 'name2': ""} # just a example
browser = await launch({"executablePath": "/usr/bin/google-chrome-stable"}, args=['--no-sandbox'], headless=True)
page = await browser.newPage()
await page.setCookie(cookies)
print('after set cookie')
response = await page.goto('http://example.com/', timeout=100000)
print('before screenshot')
await page.screenshot({'path': '/tmp/tmp.png', 'quality': 100, 'fullPage': True})
await browser.close()
asyncio.get_event_loop().run_until_complete(main())