9/3/2015 - 6:04 AM

[SOLVED] The struggle to print your u of s schedule without unnecessary details filling up the page

[SOLVED] The struggle to print your u of s schedule without unnecessary details filling up the page

import sys
import re

class Beautify:
    def __init__(self, fname):
        self.head = \
            <link rel="stylesheet" href="%s">
        """ % ""

        with open(fname, 'r') as f:
            self.htmlstring =

    def filter_html(self):
        table_style = "table table-striped table-bordered table-condensed"
        reg = re.compile('<table(.*?)class=".*?"(.*?)>(.*</table>)', re.S|re.I)
        table =
        table_cleaned = reg.sub(r'<table\1class="%s"\2>\3'%table_style, table)
        table_cleaned = re.sub(r'\s*class="d.*?"', '', table_cleaned)
        table_cleaned = re.sub(r'href=".*?"', '', table_cleaned)
        self.htmlstring = self.head + """\n<body class=table-responsive>\n
        <div style=\"display:inline-block;\">\n""" + table_cleaned + "\n</div>\n</body>"

    def writeout(self, fname):
        with open(fname + ".html", 'w+') as out:

if __name__ == '__main__':
    cleaner = Beautify(sys.argv[1])

This is a method to get a clear, printable version of your uofs time table. This method involves a little work from you, then the attached app below does the rest. For this method to work well, you need to use firefox browser, as the end result looks off on chrome.

  1. Open your schedule in a browser:

  1. Right-click anywhere in the page and select Inspect Element:

  2. Inside the new window, type table.datadisplaytable into the search bar:

  3. Finally right click the highlighted row and select Copy Outer HTML or Copy HTML

  4. Copy this into a file and save the file. Assuming you called the file sched.html, here is how you will then use the script:

python sched.html out
  1. After the script has run it's course, it will produce a file called out.html. Open this file in your browser to see your schedule. Example:

  1. Print preview in this new page shows this:


  1. To convert the file to a pdf (thus preserving the colours), use this site to do so: