[Python] Extract table from (GitHub) Markdown page into Python data structure

Discussão em 'Python' iniciado por Stack, Julho 21, 2025.

  1. Stack

    Stack Membro Participativo

    I wanted to extract a table from a GitHub Markdown page into a Python data structure, preferably a pandas dataframe, but a dictionary or anything else is in principle also fine. So I thought I to start with requests.get(), and then use the markdown package to get the tables. But this is apparently not the end of the story.

    This is what I have so far:

    import markdown
    import requests

    url = "https://github.com/alfkoehn/fusion_plots/blob/master/fusion_companies/fusion_companies.md"

    response = requests.get(url)
    html = markdown.markdown(response.content)


    I guess next would be a bs4.BeautifulSoup(html, 'html.parser') call, but that is not really helpful. How do I extract the, in this case two, tables from the Markdown webpage?

    Continue reading...

Compartilhe esta Página