Skip to content

Instantly share code, notes, and snippets.

@jonwitts
Created June 6, 2020 14:13
Show Gist options
  • Save jonwitts/9490d11a9f3da463ccea133e9397582f to your computer and use it in GitHub Desktop.
Save jonwitts/9490d11a9f3da463ccea133e9397582f to your computer and use it in GitHub Desktop.
# import the panda module - install https://pandas.pydata.org/docs/getting_started/install.html#installing-from-pypi
import pandas as pd
# read the webpage into python
url = r'https://en.wikipedia.org/wiki/FTSE_100_Index?fbclid=IwAR2V6kJA4d6mNqJaouVZ3ule6nuV4YS8tKtJutW98M_wmtQblHtcZOgmmVI'
tables = pd.read_html(url) # Returns list of all tables on page
ftse = (tables[2]) # the third table in the webpage (zero indexed lists in python)
print(ftse) # check we have the data
# save csv to path_or_buf - Change to location
ftse.to_csv(path_or_buf="/home/jon/Desktop/ftse.csv", index=False)
print("finished")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment