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