Created
December 2, 2016 16:52
-
-
Save jxnl/096f3b651b268b7af4c8c32475fa23d1 to your computer and use it in GitHub Desktop.
program checks if i'll ever graduate on time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mechanize | |
import pandas as pd | |
import os | |
from bs4 import BeautifulSoup | |
from IPython.core.display import display, HTML | |
br = mechanize.Browser() | |
br.open("http://www.adm.uwaterloo.ca/infocour/CIR/SA/under.html") | |
br.select_form(nr=0) | |
br.form["subject"] = ["CS"] | |
br.form["cournum"] = "230" | |
br.submit() | |
soup = BeautifulSoup(br.response().read()) | |
table = pd.read_html(str(soup.table.table))[0] | |
table.columns = table.loc[0,:] | |
table = table.loc[1:,:] | |
table = table.set_index(["Class", "Comp Sec"]) | |
can_enroll = (table["Enrl Cap"] > table["Enrl Tot"]).any() | |
if can_enroll: | |
os.system('say "time to enroll"') | |
print("time to enroll") | |
else: | |
os.system('say "you will never graduate on time"') | |
print("you will never graduate on time") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment