【问题标题】:requests_html TimeoutError: Navigation Timeout Exceeded: 9000 ms exceededrequests_html TimeoutError: Navigation Timeout Exceeded: 超过 9000 ms
【发布时间】:2020-08-24 15:13:53
【问题描述】:

我想使用requests_html 抓取一个动态网站https://www.woorank.com/en/www/webmatrices.com(即加载需要时间 - JAVASCRIPTED)。当它尝试下面的代码时,会弹出一个错误。 目前我在我的电脑上使用它,但我将在我的服务器上使用它。 我不想要任何 selenium 推荐,因为我的服务器中没有安装 java,因此我可以在我的服务器中运行它。

from requests_html import HTMLSession
asession = HTMLSession()
headers = {
    'user-agent':'Mozilla/5.0',
    'x-requested-with': 'XMLHttpRequest'
}
r = asession.get('https://www.woorank.com/en/www/webmatrices.com', headers = headers)

file = open('newsite.html', 'w+')
file.write(str(r.html.render(timeout=9)))
file.close()

这是弹出的错误:

  File "C:\Users\Dell\AppData\Roaming\Python\Python38\site-packages\requests_html.py", line 512, in _async_render
    await page.goto(url, options={'timeout': int(timeout * 1000)})
  File "C:\Users\Dell\AppData\Roaming\Python\Python38\site-packages\pyppeteer\page.py", line 885, in goto
    raise error
pyppeteer.errors.TimeoutError: Navigation Timeout Exceeded: 9000 ms exceeded.
enter code here

【问题讨论】:

    标签: python python-requests python-requests-html


    【解决方案1】:

    您只需将渲染超时参数增加到大于 9 的值。试试r.html.render(30)

    【讨论】:

      猜你喜欢
      • 2020-02-16
      • 2022-10-14
      • 2019-08-30
      • 2016-09-13
      • 1970-01-01
      • 2015-10-29
      • 2023-03-04
      • 2022-01-25
      • 1970-01-01
      相关资源
      最近更新 更多