import requests
import http.cookiejar
import time

def download_raw_data():
    url = 'http://coursefinder.utoronto.ca/course-search/search/courseSearch/course/search'

    data = {
        'queryText': '',
        'requirements': '',
        'campusParam': 'St. George,Scarborough,Mississauga'
    }

    cookies = http.cookiejar.CookieJar()
    s = requests.Session()

    # Keep trying to get data until a proper response is given
    json = None
    while json is None:
        r = s.get(url, params=data, cookies=cookies)
        if r.status_code == 200:
            json = r.text
        else:
            time.sleep(0.5)

    # Output to file
    f = open('raw_data.json', 'wb')
    f.write(json.encode('utf-8'))
    f.close()

@@ -48,33 +48,254 @@
 me%0A%0A
-def download_raw_data():%0A
+class CourseFinder:%0A    %22%22%22 Some sort of description%0A    - stuff%0A    %22%22%22%0A%0A    def __init__(self):%0A        pass%0A%0A    def search(self, query='', requirements=''):%0A        %22%22%22 Perform a UofT Course Finder search and return the data.%0A        %22%22%22%0A    
     
@@ -383,16 +383,20 @@
 earch'%0A%0A
+    
     data
@@ -400,16 +400,20 @@
 ata = %7B%0A
+    
         
@@ -425,20 +425,27 @@
 yText': 
-'',%0A
+query,%0A    
         
@@ -464,12 +464,26 @@
 s': 
-'',%0A
+requirements,%0A    
     
@@ -546,11 +546,19 @@
     
+  
+  
 %7D%0A%0A
+    
     
@@ -594,16 +594,20 @@
 ieJar()%0A
+    
     s = 
@@ -630,16 +630,20 @@
 ()%0A%0A    
+   
+ 
 # Keep t
@@ -693,16 +693,20 @@
 s given%0A
+    
     json
@@ -713,16 +713,20 @@
  = None%0A
+    
     whil
@@ -741,16 +741,20 @@
 s None:%0A
+    
         
@@ -806,16 +806,20 @@
         
+    
 if r.sta
@@ -843,24 +843,28 @@
             
+    
 json = r.tex
@@ -864,13 +864,19 @@
 = r.
-text%0A
+json()%0A    
     
@@ -885,16 +885,20 @@
   else:%0A
+    
         
@@ -926,105 +926,20 @@
     
-# Output to file%0A    f = open('raw_data.json', 'wb')%0A    f.write(json.encode('utf-8'))%0A    f.close()
+    return json
 %0A

hashtag OOP