【发布时间】:2019-02-02 22:14:39
【问题描述】:
我正在使用 python 3.7 开发一个网络抓取应用程序。我正在使用 requests-html 来解析数据。到目前为止,我已经尝试了以下代码来尝试使用渲染功能(因为 fast.com 上的速度数据是通过 javascript 加载的)。
from requests_html import HTMLSession
quote_page = 'https://fast.com'
session = HTMLSession()
r = session.get(quote_page)
r.html.render()
extract_value = r.html.find('#speed-value', first=True)
print(extract_value.text)
speed-value是包含速度数据的div使用的id属性。
但它仍然将速度值打印为 0。
【问题讨论】:
-
为什么要把事情搞得这么复杂,在 python 本身中检查互联网速度。
标签: python-3.x python-requests-html