【发布时间】:2012-05-07 06:54:58
【问题描述】:
我需要解析 html 表格以执行诸如获取某个单元格上方/下方或左/右列中的所有单元格之类的操作。有没有可以轻松做到这一点的python库?
【问题讨论】:
标签: python html-parsing html-table
我需要解析 html 表格以执行诸如获取某个单元格上方/下方或左/右列中的所有单元格之类的操作。有没有可以轻松做到这一点的python库?
【问题讨论】:
标签: python html-parsing html-table
此代码将页面中的所有表格转换为列表。
import pandas as pd
url = r'https://en.wikipedia.org/wiki/List_of_S%26P_500_companies'
tables = pd.read_html(url) # Returns list of all tables on page
sp500_table = tables[0] # Select table of interest
【讨论】:
【讨论】: