模拟登录后抓取成绩,计算绩点。
002pc.com认为此文章对《python把多个一维数组变成二维数组python爬取并计算成绩》说的很在理。# -*- coding: utf-8 -*-
import urllib
import urllib2
import cookielib
import re
import string
#绩点运算
class SDU:
#类的初始化
def __init__(self):
#登录URL
self.loginUrl = 'http://jwxt.sdu.edu.cn:7890/pls/wwwbks/bks_login2.login'
#成绩URL
self.gradeUrl = 'http://jwxt.sdu.edu.cn:7890/pls/wwwbks/bkscjcx.curscopre'
#CookieJar对象
self.cookies = cookielib.CookieJar()
#表单数据
self.postdata = urllib.urlencode({
'stuid':'201200131012',
'pwd':'xxxxx'
})
#构建opener
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookies))
#学分list
self.credit = []
#成绩list
self.grades = []
def getPage(self):
req = url