python快速获取网页标准表格内容


from html_table_parser  import HTMLTableParser

def tableParse(value):
    p = HTMLTableParser()
    p.feed(value)
    print(p.tables)
import pandas as pd

def framParse(value):
        soup=BeautifulSoup(value, 'html.parser')
        tables = soup.select('table')
        print(tables)
        df_list = []
        for table in tables:
            print(pd.read_html(table.prettify()))
            df_list.append(pd.concat(pd.read_html(table.prettify())))
        df = pd.concat(df_list)
        df.to_excel('vscode快捷键大全.xlsx')

以上两种方式均可以解析标准表格


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM