# https://saturncloud.io/blog/how-to-extract-tables-from-html-with-python-and-pandas/

import pandas as pd
from bs4 import BeautifulSoup


# Library for opening url and creating
# requests
import urllib.request
import ssl

# pretty-print python data structures
from pprint import pprint

from io import StringIO

# Opens a website and read its
# binary contents (HTTP Response Body)
def url_get_contents(url):

	# Opens a website and read its
	# binary contents (HTTP Response Body)

	#making request to the website
	req = urllib.request.Request(url=url)
	f = urllib.request.urlopen(req)

	#reading contents of the website
	return f.read()

# https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error
ssl._create_default_https_context = ssl._create_unverified_context

webpage = url_get_contents('https://cset2.stcc.edu/~csetuser/pandas/index.html')

# Read the HTML file into a Pandas dataframe
soup = BeautifulSoup(webpage, 'html.parser')
tables = pd.read_html(StringIO(str(soup)))

# Extract the table from the dataframe
table = tables[0]
print(table)



