In [1]:
# Code attribution: Yiyin Shen, Tyler Caraza-Harter
# Imports
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
import pandas
import matplotlib.pyplot as plt
In [2]:
# Find the second table and scrape it
service = Service(executable_path="chromedriver-win64/chromedriver.exe")
driver = webdriver.Chrome(service=service)
url = "https://pages.cs.wisc.edu/~yw/CS320F23T19.html"
driver.get(url)
tables = driver.find_elements("tag name", "table")
table = tables[1]
rows = table.find_elements("tag name", "tr")
array = []
for row in rows:
cols = row.find_elements("tag name", "td")
list = []
for col in cols:
list.append(col.text)
array.append(list)
pandas.DataFrame(array)
Out[2]:
0 | 1 | 2 | |
---|---|---|---|
0 | 3 | 2 | 0 |
1 | 2 | 2 | 0 |
2 | 0 | 0 | 0 |
In [3]:
# Remember to quit when it's done
driver.quit()