[Python] How to extract tables from websites in Python

Discussão em 'Python' iniciado por Stack, Maio 10, 2025.

  1. Stack

    Stack Membro Participativo

    Here,

    http://www.ffiec.gov/census/report.aspx?year=2011&state=01&report=demographic&msa=11500


    is a table. My goal is to extract the table and save it to a CSV file. I wrote some code:

    import urllib
    import os

    web = urllib.urlopen("http://www.ffiec.gov/census/report.aspx?year=2011&state=01&report=demographic&msa=11500")

    s = web.read()
    web.close()

    ff = open(r"D:\ex\python_ex\urllib\output.txt", "w")
    ff.write(s)
    ff.close()


    I don't know how to go on from here. Anyone who can help? Thanks!

    Continue reading...

Compartilhe esta Página