The reason for the error: the pyppeteer framework is asynchronous, so the internal delay method must also be asynchronous, otherwise this error will be thrown
future: <Future finished exception=NetworkError('Protocol error (Target.detachFromTarget): No session with given id')
Reference: https://github.com/pyppeteer/pyppeteer/issues/89
Refer to https://github.com/ranksense/url-inspector-automator/issues/1
Official solution: https://github.com/miyakogi/pyppeteer/issues/194
error code:
if some:
do something
else:
try:
do something
except Exception:
do something
time.sleep(0.5)
try:
do something
except Exception:
pass
Modified code [The delay here must be an asynchronous delay method, here time.sleep will report this error]:
if some: do something else: try: do something except Exception: do something
await asyncio.sleep(0.5) # or await page.waitFor(10)
try: do something except Exception: pass