Esempio n. 1
0
def pasth(request):
    context = RequestContext(request)
    if request.user.is_authenticated():
        data = request.POST.get('test')
        results = list()
        pq = PyQuery(data)
        coursesFound = 0
        tempSchedule = Schedule()
        for c in pq('tr'):
            results.append(pq(c).text())

            #find out if this is class data
            query = "COURSE SECT GRADE CREDIT CREDIT EARNED CREDIT FOR GPA COURSE TITLE"

            if pq(c).text(
            ) == query:  #go through the page to find when courses first appear
                coursesFound = 1
                #print "found courses" #debug log

            else:  #if it is not a header then do this
                if coursesFound == 1:  #if it is not a header AND courses have already been found, parse them
                    coursedata = pq(c)
                    pastClass = Course()  #temp class object
                    for d in coursedata(
                            'td'):  # break the tr down into it's td values
                        #print coursedata(d).text() #debugging logs

                        length = len(
                            coursedata(d).text()
                        )  #get the length of the data so we know what field it is

                        if length == 8:
                            pastClass.name = coursedata(d).text()
                        else:
                            if length == 4:
                                pastClass.section = coursedata(
                                    d).text()  #0000 for transfer classes
                            else:
                                if length == 1 or length == 2:
                                    pastClass.finalgrade = coursedata(d).text()
                                else:
                                    if length == 3:
                                        pastClass.cedits = coursedata(d).text(
                                        )  #note: there can be multiple credit fields (credits earned, for gpa, credits), we are grabbing the very last one
                                    else:
                                        pastClass.cname = coursedata(d).text()
                    tempSchedule.add(pastClass)

        user_profile = request.user.get_profile()
        user_profile.pastHistory = tempSchedule
        #go to user profile and add tempschedule

        return render_to_response('pasth.html', {
            "results": results,
        },
                                  context_instance=context)

    else:
        return render_to_response('nsi.html', context_instance=context)
Esempio n. 2
0
def pasth(request):
    context = RequestContext(request)
    if request.user.is_authenticated(): 
        data = request.POST.get('test')
        results = list()
        pq = PyQuery(data)
        coursesFound = 0;
        tempSchedule = Schedule()
        for c in pq('tr'):
            results.append(pq(c).text())
	
			#find out if this is class data
            query = "COURSE SECT GRADE CREDIT CREDIT EARNED CREDIT FOR GPA COURSE TITLE"
			
			
            if pq(c).text() == query: #go through the page to find when courses first appear 
				coursesFound = 1
				#print "found courses" #debug log
				
            else: #if it is not a header then do this
				if coursesFound == 1: #if it is not a header AND courses have already been found, parse them
					coursedata = pq(c)
					pastClass = Course() #temp class object 
					for d in coursedata('td'): # break the tr down into it's td values
						#print coursedata(d).text() #debugging logs 
						
						length = len(coursedata(d).text()) #get the length of the data so we know what field it is
						
						if length == 8:
							pastClass.name = coursedata(d).text()
						else: 
							if length == 4:
								 pastClass.section = coursedata(d).text() #0000 for transfer classes
							else:
								if length == 1 or length == 2:
									pastClass.finalgrade = coursedata(d).text() 
								else:
									if length == 3:
										pastClass.cedits = coursedata(d).text() #note: there can be multiple credit fields (credits earned, for gpa, credits), we are grabbing the very last one 
									else:
										pastClass.cname = coursedata(d).text()
					tempSchedule.add(pastClass)
						
        user_profile = request.user.get_profile()				
        user_profile.pastHistory = tempSchedule; #go to user profile and add tempschedule	
			
        return render_to_response('pasth.html', {"results": results,}, context_instance=context)

    else:
        return render_to_response('nsi.html', context_instance=context)
Esempio n. 3
0
    def handle(self, *args, **options):
        updateR = False
        if options['rating']:
            updateR = True
        url = "http://www.registrar.ufl.edu/soc/201401/all/"
        page = urllib2.urlopen(url)
        soup = BeautifulSoup(page)
        list1 = list()  # list of categories
        list2 = list()  #list of website endings
        soup2 = [option.get('value') for option in soup.findAll('option')]
        contents = [str(x.text) for x in soup.find_all('option')]
        x = 0
        for value in contents:
            # all option values all DEPARTMENTS
            list1.append(value)

        for value in soup2:
            # all endings for the web addresses per department
            list2.append(value)

        for idx, website in enumerate(list2):
            temp1 = website.strip()
            if not not temp1:
                print "OPENING: " + url + website
                page = urllib2.urlopen(url + website)
                pages = str(page.read())

                started = False
                moveA = False
                count = 0
                y = 0
                g = Course('0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                           '0', '0', '0', '0', '0', '0')
                pq = PyQuery(pages)
                tag = pq('td')
                index = list2.index(website)

                for c in pq('td'):
                    if (pq(c).text().__len__() == 8 and pq(c).text()[3:4]
                            == " ") or (pq(c).text().__len__() == 9
                                        and pq(c).text()[3:4] == " "):
                        y = 0
                        x = x + 1

                        if g.name != '0':
                            g.dept = list1[
                                index]  # Department added to each course
                            g.save()

                        g = Course(x, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
                                   ' ', ' ', ' ', ' ', ' ', ' ', ' ')
                        g.name = pq(c).text()
                        started = True
                        moveA = False

                    if (not (pq(c).text().__len__() == 8
                             and pq(c).text()[3:4] == " ") or
                        (pq(c).text().__len__() == 9
                         and pq(c).text()[3:4] == " ")) and started == True:
                        y = y + 1
                        if y == 7 and moveA != True:
                            g.lday = pq(c).text()
                        if y == 21 and moveA != True:
                            g.dday = pq(c).text()
                        if y == 22 and moveA != True:
                            g.dtime = pq(c).text()
                        if y == 23 and moveA != True:
                            g.dbuild = pq(c).text()
                        if y == 24 and moveA != True:
                            g.droom = pq(c).text()
                        if y == 5 and moveA != True:
                            if (len(pq(c).text()) == 0) or (len(pq(c).text())
                                                            == 1):
                                moveA = True
                            else:
                                g.section = pq(c).text()
                        if y == 6 and moveA != True:
                            g.cedits = pq(c).text()
                        if y == 8 and moveA != True:
                            g.ltime = pq(c).text()
                        if y == 9 and moveA != True:
                            g.lbuild = pq(c).text()
                        if y == 10 and moveA != True:
                            g.lroom = pq(c).text()
                        if y == 12 and moveA != True:
                            g.cname = pq(c).text()
                        if y == 13 and moveA != True:
                            g.cinst = pq(c).text()
                            if updateR:
                                g.rmpr = getrmp(g.cinst, count)
                                count = count + 1

                        if y == 6 and moveA == True:
                            g.section = pq(c).text()
                        if y == 7 and moveA == True:
                            g.cedits = pq(c).text()
                        if y == 9 and moveA == True:
                            g.ltime = pq(c).text()
                        if y == 22 and moveA == True:
                            g.dday = pq(c).text()
                        if y == 23 and moveA == True:
                            g.dtime = pq(c).text()
                        if y == 24 and moveA == True:
                            g.dbuild = pq(c).text()
                        if y == 25 and moveA == True:
                            g.dbuild = pq(c).text()
                        if y == 8 and moveA == True:
                            g.lday = pq(c).text()
                        if y == 10 and moveA == True:
                            g.lbuild = pq(c).text()
                        if y == 11 and moveA == True:
                            g.lroom = pq(c).text()
                        if y == 13 and moveA == True:
                            g.cname = pq(c).text()
                        if y == 14 and moveA == True:
                            g.cinst = pq(c).text()
                            if updateR:
                                g.rmpr = getrmp(g.cinst, count)
                                count = count + 1

                        if y == 36 and moveA == True:
                            g.d2day = pq(c).text()
                        if y == 37 and moveA == True:
                            g.d2time = pq(c).text()
                        if y == 38 and moveA == True:
                            g.d2build = pq(c).text()
                        if y == 39 and moveA == True:
                            g.d2room = pq(c).text()
Esempio n. 4
0
    def handle(self, *args, **options):
            updateR = False
            if options['rating']:
                updateR = True    
            url = "http://www.registrar.ufl.edu/soc/201401/all/"
            page = urllib2.urlopen(url)
            soup = BeautifulSoup(page)
            list1 = list()      # list of categories
            list2 = list()      #list of website endings
            soup2 = [option.get('value') for option in soup.findAll('option')]
            contents = [str(x.text) for x in soup.find_all('option')]
            x = 0
            for value in contents:
                # all option values all DEPARTMENTS
                list1.append(value)
                
            for value in soup2:
                # all endings for the web addresses per department 
                list2.append(value)

            for idx, website in enumerate(list2):
                temp1 = website.strip()
                if not not temp1:
                    print "OPENING: " + url + website
                    page = urllib2.urlopen(url+ website)
                    pages = str( page.read()) 
                    
                    started = False
                    moveA = False
                    count = 0
                    y = 0
                    g = Course('0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0')
                    pq = PyQuery(pages)
                    tag = pq('td')
                    index = list2.index(website)
                    
                    for c in  pq('td'):
                        if (pq(c).text().__len__() == 8 and pq(c).text()[3:4] == " ") or (pq(c).text().__len__() == 9 and pq(c).text()[3:4] == " "):
                                y = 0
                                x= x+1
                                
                                if g.name != '0':
                                    g.dept = list1[index] # Department added to each course
                                    g.save()
                                    
                                g = Course(x,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
                                g.name = pq(c).text()
                                started = True
                                moveA = False
                                
                        if (not (pq(c).text().__len__() == 8 and pq(c).text()[3:4] == " ") or (pq(c).text().__len__() == 9 and pq(c).text()[3:4] == " ")) and started == True:
                                y = y+1
                                if y == 7 and moveA != True:
                                     g.lday = pq(c).text()
                                if y == 21 and moveA != True:
                                     g.dday = pq(c).text()
                                if y == 22 and moveA != True:
                                     g.dtime = pq(c).text()
                                if y == 23 and moveA != True:
                                     g.dbuild = pq(c).text()
                                if y == 24 and moveA != True:
                                     g.droom = pq(c).text()
                                if y == 5 and moveA != True:
                                     if (len(pq(c).text()) == 0) or (len(pq(c).text()) == 1):
                                             moveA = True
                                     else: g.section = pq(c).text()
                                if y == 6 and moveA != True:
                                     g.cedits = pq(c).text()
                                if y == 8 and moveA != True:
                                     g.ltime = pq(c).text()
                                if y == 9 and moveA != True:
                                     g.lbuild = pq(c).text()
                                if y == 10 and moveA != True:
                                     g.lroom = pq(c).text()
                                if y == 12 and moveA != True:
                                     g.cname = pq(c).text()
                                if y == 13 and moveA != True:
                                     g.cinst = pq(c).text()
                                     if updateR:
                                         g.rmpr = getrmp(g.cinst,count)
                                         count = count +1
                                     
                                if y == 6 and moveA == True:
                                     g.section = pq(c).text()
                                if y == 7 and moveA == True:
                                     g.cedits = pq(c).text()
                                if y == 9 and moveA == True:
                                     g.ltime = pq(c).text()
                                if y == 22 and moveA == True:
                                     g.dday = pq(c).text()
                                if y == 23 and moveA == True:
                                     g.dtime = pq(c).text()
                                if y == 24 and moveA == True:
                                     g.dbuild = pq(c).text()
                                if y == 25 and moveA == True:
                                     g.dbuild = pq(c).text()
                                if y == 8 and moveA == True:
                                     g.lday = pq(c).text()
                                if y == 10 and moveA == True:
                                     g.lbuild = pq(c).text()
                                if y == 11 and moveA == True:
                                     g.lroom = pq(c).text()
                                if y == 13 and moveA == True:
                                     g.cname = pq(c).text()
                                if y == 14 and moveA == True:
                                     g.cinst = pq(c).text()
                                     if updateR:
                                         g.rmpr = getrmp(g.cinst,count)
                                         count = count +1
                                         
                                if y == 36 and moveA == True:
                                     g.d2day = pq(c).text()
                                if y == 37 and moveA == True:
                                     g.d2time = pq(c).text()
                                if y == 38 and moveA == True:
                                     g.d2build = pq(c).text()
                                if y == 39 and moveA == True:
                                     g.d2room = pq(c).text()