我是新的网页抓取,我需要一些帮助我的查询。 在这一页https://ski-resort-stats.com/Hemsedal/,HEMSEDAL的雪历史部分,我试图检索图表上的信息(每年的降雪量)。我试图从一年(2013-2014)开始
我想我在html代码中找到了相关的部分: Screenshot from the html code
为此:
from bs4 import BeautifulSoup
import requests
url="https://ski-resort-stats.com/Hemsedal/"
html_content = requests.get(url).text
soup = BeautifulSoup(html_content, "lxml")
gdp_table = soup.find("g", attrs={"class": "highcharts-markers highcharts-series-0 highcharts-spline-series highcharts-color-0 highcharts-tracker"})
gdp_table_data = gdp_table.tbody.find_all("path")`
但我要纠正这个错误:“AttributeError:'非类型'对象没有属性'tbody'”。尝试使用html代码中的其他元素,但未成功。有人能帮我吗
正如@joni所指出的,该站点在最初加载javascript之后运行javascript,用图形数据填充页面。下面的代码使用^{} 加载页面,在图上抓取
2013-2014
的数据点元素,然后将鼠标悬停在每个点上,以便显示包含实际数据的信息工具提示:输出:
数据以JavaScript形式嵌入到页面中。您可以使用以下示例来解析它:
印刷品:
相关问题 更多 >
编程相关推荐