pyppeteer icon indicating copy to clipboard operation
pyppeteer copied to clipboard

pyppeteer.errors.NetworkError: Protocol Error: Cannot find context with specified id None

Open csugzq opened this issue 6 years ago • 5 comments

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

csugzq avatar Apr 12 '18 10:04 csugzq

Thank you for information. I will check the puppeteer's issue.

miyakogi avatar Apr 13 '18 02:04 miyakogi

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)

keithhackbarth avatar May 13 '18 18:05 keithhackbarth

FTR https://github.com/GoogleChrome/puppeteer/issues/1325 was closed in June

immerrr avatar Jul 14 '18 21:07 immerrr

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

civanescu avatar Feb 19 '19 07:02 civanescu

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

ytldsimage avatar Sep 13 '19 11:09 ytldsimage