【发布时间】: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