コード例 #1
0
ファイル: qdu.py プロジェクト: adamwen/QSSA
    def run(self,schoolId,pw,email,password):
        cookie = cookielib.CookieJar()
        cookieProc = urllib2.HTTPCookieProcessor(cookie)
    
        enable_proxy = True #close the proxy mode
        proxy_handler = urllib2.ProxyHandler({'http': 'http://184.82.244.128:21'})

        if enable_proxy == True:
            opener = urllib2.build_opener(cookieProc,proxy_handler)
        else:
            opener = urllib2.build_opener(cookieProc)
    
        urllib2.install_opener(opener)



        url = 'http://jw.qdu.edu.cn/academic/j_acegi_security_check?j_username='******'&j_password='******'&username=&password=&login=%E7%99%BB%E5%BD%95'
        response = urllib2.urlopen(url)
        htmlCode = urllib2.urlopen('http://jw.qdu.edu.cn/academic/student/currcourse/currcourse.jsdo?year=32&term=2').read().decode('gbk').encode('UTF-8')

        soup = BeautifulSoup(htmlCode) 

        body = soup.find_all('tr','infolist_common')

        length = len(body) - 19

        classInfoList = []

        sample = CalendarList(email,password)

        for i in range(0,length):
            lesson = ClassInfo(body[i])
            for elem in lesson.info:
                recurrence = recurrence_data_processor(elem)
                lesson_title = lesson.get_name()
                teacher = '任课教师:' + lesson.get_teacher()
                place = elem['place']
                sample._InsertEvent(title=lesson_title,content=teacher,where=place,recurrence_data=recurrence)
コード例 #2
0
ファイル: views.py プロジェクト: adamwen/QSSA
def run(schoolId,pw,email,password):
    cookie = cookielib.CookieJar()
    cookieProc = urllib2.HTTPCookieProcessor(cookie)
   

    opener = urllib2.build_opener(cookieProc)
    
    urllib2.install_opener(opener)


    pw = urllib.quote(pw)
    url = 'http://jw.qdu.edu.cn/academic/j_acegi_security_check?j_username='******'&j_password='******'&username=&password=&login=%E7%99%BB%E5%BD%95'
    response = urllib2.urlopen(url)
    htmlCode = urllib2.urlopen('http://jw.qdu.edu.cn/academic/student/currcourse/currcourse.jsdo?year=32&term=2').read().decode('gbk').encode('UTF-8')

    soup = BeautifulSoup(htmlCode) 

    body = soup.find_all('tr','infolist_common')
    length = len(body) - 19

    try:
        if length < 0:
            raise Exception('school')

        classInfoList = []
        #sample = CalendarList(email,password)
        for i in range(0,length):
            lesson = ClassInfo(body[i])
            for elem in lesson.info:
                recurrence = recurrence_data_processor(elem)
                lesson_title = lesson.get_name()
                teacher = lesson.get_teacher()
                place = elem['place']
                print lesson_title,teacher,place
                #sample._InsertEvent(title=lesson_title,content=teacher,where=place,recurrence_data=recurrence)
    except Exception,e:
        raise Exception(str(e))
コード例 #3
0
ファイル: qdu.py プロジェクト: adamwen/QSSA
email = raw_input("Please input your gmail account:")
password = getpass.getpass("Please input your password:")





url = 'http://jw.qdu.edu.cn/academic/j_acegi_security_check?j_username='******'&j_password='******'&username=&password=&login=%E7%99%BB%E5%BD%95'
response = urllib2.urlopen(url)
htmlCode = urllib2.urlopen('http://jw.qdu.edu.cn/academic/student/currcourse/currcourse.jsdo?year=32&term=2').read().decode('gbk').encode('UTF-8')

soup = BeautifulSoup(htmlCode) 

body = soup.find_all('tr','infolist_common')

length = len(body) - 19

classInfoList = []

sample = CalendarList(email,password)

for i in range(0,length):
    lesson = ClassInfo(body[i])
    for elem in lesson.info:
        recurrence = recurrence_data_processor(elem)
        lesson_title = lesson.get_name()
        teacher = '任课教师:' + lesson.get_teacher()
        place = elem['place']
        sample._InsertEvent(title=lesson_title,content=teacher,where=place,recurrence_data=recurrence)