[683]pyppeteer.errors.TimeoutError: Navigation Timeout Exceeded: 30000 ms exceeded

  • 2020 年 1 月 13 日
  • 筆記

使用pyppeteer使用代理,由于没有设置超时,是系统默认超时

错误提示如:

pyppeteer.errors.TimeoutError: Navigation Timeout Exceeded: 30000 ms exceeded

解决方法添加超时时间:

第一种方法:

await page.setDefaultNavigationTimeout(timeout)

第二种方法:

await page.goto(url,{      'timeout': 1000*60 //这里超时是60s  })  //timeout => 是以毫秒为单位    async def test():      proxy = '103.28.206.65:888'      # headless参数设为False,则变成有头模式      browser = await launch(          headless=False,          args=['--proxy-server={}'.format(proxy), ]      )      page = await browser.newPage()        await page.authenticate({          'username': 'chenxm',          'password': 'chenxm',      })      await page.goto('http://www.chenxm.cc/', {'timeout': 10000*20})

第三种方法

// set a timeout of 8 minutes  page.waitForNavigation({'timeout': 1000*30})

其实上面的问题,把websockets版本改到7.0以下即可解决

websockets.exceptions.ConnectionClosedError: code = 1006

有人说可以把python第三方库websockets版本7.0改为6.0(反正在7.0版本以下就)就可以了,亲测可用。

pip3.6 uninstall websockets #卸载websockets  pip3.6 install websockets==6.0 #指定安装6.0版本```

参考:http://www.chenxm.cc/article/825.html https://blog.csdn.net/Mr__lqy/article/details/102626025