def main(): # Set the cookie handler so we can pass around cookies # from the POST request. TODO: Should we pass in the cookie jar # to be able to read it later? If we're automating and this is # all in a loop, we'll need to be able to clear expired cookies. cookies = wu.set_url_opener() opts = parse_options() for sln in opts.sln: # Make sure none of the cookies are expired. Re-login if necessary. validate_login_cookie(cookies, opts.user, opts.password) sched_params = build_schedule_params(3, sln) # TODO: Hard coded! Change after debugging. html_str = get_schedule_page(sched_params) info = wu.parse_table_headers( ['SLN', 'Course', 'Title', 'Enrollment', 'Limit'], html_str ) print_class_info(info) # This is here because apparently quick successive # requests make the server cry. # TODO: Maybe backoff exponentially, or according to some function, if # we detect the horrifying 'missing page' time.sleep(6)
def main(): # Set the cookie handler so we can pass around cookies # for POST requests. cookies = wu.set_url_opener() opts = parse_options()