【发布时间】:2020-06-10 05:40:07
【问题描述】:
我正在尝试在this link 的 html 页面中解析一个表格,但我还没有找到一种方法来确保我可以指向正确的表格,因为该页面还包含一些其他表格 - 如图所示附上图片。
我已经尝试过更简单的方法,使用 pandas.read_html 并让它弄清楚,但这只会返回页面顶部的内容(我猜),错过了其他所有内容。
import pandas as pd
url='https://www.360optimi.com/app/sec/resourceType/benchmarkGraph?resourceSubTypeId=5c9316b28e202b46c92ca518&resourceId=envdecAluminumWindowProfAl&profileId=Saray2016&benchmarkToShow=co2_cml&entityId=5e4eae0f619e783ceb5d0732&indicatorId=lcaForLevels-CO2&stateIdOfProject='
tables = pd.read_html(url)
print(tables[0])
返回:
0 1 2
0 English Français Deutsch
1 Español Suomi Norsk
2 Nederlands Svenska Italiano
知道如何使用正确的 html 标签指向感兴趣的表吗?
编辑: 正如你们中的一些人指出的那样,网页需要登录凭据(道歉),我已经上传了 html 代码here。
【问题讨论】:
-
你是怎么登录的?
-
您感兴趣的页面要求提供登录凭据
-
@KarthickMohanraj 和 Datanovice 都道歉,我已将 html 代码复制并粘贴到 codepen 中
标签: python pandas html-table html-parsing