# User input term term_num = -1 while (term_num == -1): term_input = (raw_input("Enter the term (e.g. Spring 2016): ")).strip() if not term_input: print "Error, term not found, try again" continue term_year = term_input[-4:] term_season = term_input[:-4].strip() term_cleaned = term_season[0].upper() + term_season[1:].lower() + " " + term_year terms_info = (uw.terms())["listings"] term_num = get_term_num(terms_info, term_cleaned) if term_num == -1 or str(term_num) not in term_dates: print "Error, term not found, try again" term_num = -1 course_name = [] course_num = [] course_section = [] # User input course name and sections print ("\nEnter 'done' to finish input\n")
term_dates[1161] = {"start_date": "2016-01-04", "end_date": "2016-04-23"} term_dates[1165] = {"start_date": "2016-05-02", "end_date": "2016-08-13"} for course in uw.subject_codes(): uw_subjects.append(course.get("subject")) reddit = praw.Reddit(user_agent=USER_AGENT) reddit.login(LOGIN, PASSWORD) # Main loop while True: logging.debug("Loop") subreddit = reddit.get_subreddit(local_settings.PARAM_SUBREDDIT) subreddit_comments = subreddit.get_comments() current_term = uw.terms().get("current_term") term_dates.get(current_term) start_date = term_dates.get(current_term).get("start_date") end_date = term_dates.get(current_term).get("end_date") # Scrape subreddit comments for comment in subreddit_comments: logging.debug(comment) logging.debug(comment.id) cursor.execute("SELECT comment_id FROM comments") already_done = [r[0] for r in cursor] # Check comments that have not already been replied to if comment.id not in already_done: reply = "" # Find all comments with [[]] result = re.findall(r'\[\[(.+?)\]\]', comment.body)