Python 打开 html 个文件 Excel
Python to Open html files in Excel
我有一堆 .html 格式的采购订单,我需要提取数据并放入一个简单的 excel sheet。虽然我可以使用 beutifulsoup 来做到这一点,但我宁愿只使用 excel 的内置转换器,它已经做得更好了。然后直接使用 excel 文件。有没有办法用python打开html个文件,然后再保存成.xlsx。我尝试使用 openpyxl,但它不需要 html 个文件。
您可以使用 Python 自动执行 Excel 应用程序的实例,打开每个文件,并另存为 .xlsx
:
import win32com.client
excelApp = win32com.client.Dispatch('Excel.Application')
book = excelApp.Open(path_to_html_file)
book.SaveAs(path_to_html_file + '.xlsx', 51)
如果您想要的数据在 html 中的表中,您可以使用 tablepyxl 将 html 读入 excel。
我有一堆 .html 格式的采购订单,我需要提取数据并放入一个简单的 excel sheet。虽然我可以使用 beutifulsoup 来做到这一点,但我宁愿只使用 excel 的内置转换器,它已经做得更好了。然后直接使用 excel 文件。有没有办法用python打开html个文件,然后再保存成.xlsx。我尝试使用 openpyxl,但它不需要 html 个文件。
您可以使用 Python 自动执行 Excel 应用程序的实例,打开每个文件,并另存为 .xlsx
:
import win32com.client
excelApp = win32com.client.Dispatch('Excel.Application')
book = excelApp.Open(path_to_html_file)
book.SaveAs(path_to_html_file + '.xlsx', 51)
如果您想要的数据在 html 中的表中,您可以使用 tablepyxl 将 html 读入 excel。