pyppeteer
pyppeteer copied to clipboard
pyppeteer.errors.NetworkError: Protocol Error: Cannot find context with specified id None
The error happens frequently when I visit a websit using pyppeteer, is it a bug from puppeteer. I saw some people are discussing this issue. https://github.com/GoogleChrome/puppeteer/issues/1325
Thank you for information. I will check the puppeteer's issue.
Btw.. according to puppeteers documentation this occurs when the page is not fully loaded.
Here's how I fix in my code, basically a recursive retry loop
async def _evaluate(page, retries=0):
if retries > 10:
return await page.evaluate('document.body.innerHTML')
else:
try:
return await page.evaluate('document.body.innerHTML')
except pyppeteer.errors.NetworkError:
await asyncio.sleep(0.5)
return await _evaluate(page, retries+1)
FTR https://github.com/GoogleChrome/puppeteer/issues/1325 was closed in June
I have the same error each time I try to open a page on godaddy. But it appears almost instantly how can it be "page not fully loaded" ?
Thanks
It seems nothing changed.
ERROR:root:Execution context was destroyed, most likely because of a navigation. Traceback (most recent call last): File "/Users/ytldsimage/anaconda3/lib/python3.7/site-packages/pyppeteer/execution_context.py", line 106, in evaluateHandle 'userGesture': True, pyppeteer.errors.NetworkError: Protocol error (Runtime.callFunctionOn): Cannot find context with specified id