[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