Exemple #1
0
 def __init__(self):
     cookies = LoginMyscse.Login().getcookie()
     url = Login().getHtml(cookies)[3]  # 具体要爬取的网址
     response = s.get(url, headers=headers, cookies=cookies)
     self.res = response.text.replace('even', 'odd')
     self.getTest()
     self.toStrAttendance()
Exemple #2
0
 def __init__(self):
     cookies = LoginMyscse.Login().getcookie()
     url = Login().getHtml(cookies)[2]  # 具体要爬取考试时间表的网址
     response = s.get(url, headers=headers, cookies=cookies)
     self.res = response.text.replace('even', 'odd')
     self.soup = bs4.BeautifulSoup(self.res, 'lxml')
     self.getExamtable()
     self.toStrExam()
Exemple #3
0
 def getInfo(self):
     try:
         cookies = LoginMyscse.Login().getcookie()
         url = Login().getHtml(cookies)[0]  # 具体要爬取个人信息网址
         response = s.get(url, headers=headers, cookies=cookies)
         self.soup = bs4.BeautifulSoup(response.text, 'lxml')
         self.divElem = self.soup.select('div[align="left"]')
         self.adminElem = self.soup.select('td[class="td_left"]')
         self.admin = self.adminElem[8].text.strip()
         self.admin = ''.join(self.admin.split())
         for i in range(len(self.divElem)):
             self.divElem[i] = self.divElem[i].text.strip()
     except:
         return '信息获取失败'
Exemple #4
0
    def toStrCourseInfo(self):
        cookies = LoginMyscse.Login().getcookie()
        url = Login().getHtml(cookies)[0]  # 具体要爬取个人信息网址
        response = s.get(url, headers=headers, cookies=cookies)
        res = response.text.replace('even', 'odd')  #统一所有的tr元素
        soup = bs4.BeautifulSoup(res, 'lxml')
        trElem = soup.select('tr[class="odd"]')

        self.allcourselist = []  #所有课程信息的列表
        self.allcompulsorylist = []  #所有必修课程信息的列表
        self.allelectivelist = []  #所有选修课程信息的列表
        temp = ''
        for i in range(len(trElem)):
            td = trElem[i].select('td')
            for j in range(len(td)):
                td[j] = td[j].text
            self.allcourselist.append(td)
            if len(td) == 10:
                if td[0] != '':  #开课学期不为空则拿出来
                    temp = td[0]
                else:
                    td[0] = temp  #将开课学期补充
                self.allcompulsorylist.append(td)
            elif len(td) == 9:
                self.allelectivelist.append(td)

        self.str = '必修\n'
        self.str += '课程名称' + '    ' + '成绩' + '    ' + '已得学分\n'
        for i in self.allcompulsorylist:
            if '2017年第一学期' == i[7].encode('utf-8'):
                self.str += i[2].encode('utf-8') + '(' + i[1].encode(
                    'utf-8') + ')    ' + i[-2].encode(
                        'utf-8') + '    ' + i[-1].encode('utf-8') + '\n'

        self.str += '\n选修\n'
        self.str += '课程名称' + '    ' + '成绩' + '    ' + '已得学分\n'
        for i in self.allelectivelist:
            if '2017年第一学期' == i[6].encode('utf-8'):
                self.str += i[1].encode('utf-8') + '(' + i[0].encode(
                    'utf-8') + ')    ' + i[-2].encode(
                        'utf-8') + '    ' + i[-1].encode('utf-8') + '\n'

        soup = bs4.BeautifulSoup(response.text, 'lxml')
        # 获取当前绩点
        nowGAPElem = self.soup.select('font[color="#FF0000"]')
        nowGAP = nowGAPElem[-1].text
        # 获取学分和成绩
        self.listg = []
        for i in self.allcompulsorylist + self.allelectivelist:
            if i[-1].strip():
                self.listg.append(
                    [i[-1].encode("utf-8"), i[-2].encode("utf-8")])
        # 计算绩点
        credit = 0
        score = 0
        for i in self.listg:
            credit += float(i[0])
            tmpStr = i[1].replace("(补)", "")
            if tmpStr == "优":
                score += 95 * float(i[0])
            elif tmpStr == "良":
                score += 85 * float(i[0])
            elif tmpStr == "中":
                score += 75 * float(i[0])
            elif tmpStr == "及格" or tmpStr == "合格":
                score += 65 * float(i[0])
            elif tmpStr == "不及格":
                score += 0 * float(i[0])
            else:
                score += int(tmpStr) * float(i[0])
        calGPA = (score / credit) / 10 - 5

        GAP0 = str(round(calGPA, 1))
        GAP1 = str(round(calGPA, 4))
        GAP = u'当前绩点:' + nowGAP + u'\n预计绩点:' + GAP0 + u'(' + GAP1 + u')\n仅供参考,实际绩点以系统更新为准'

        return self.str + GAP.encode("utf8")
Exemple #5
0
 def __init__(self):
     cookies = LoginMyscse.Login().getcookie()
     url = Login().getHtml(cookies)[1]  # 具体要爬取课程表网址
     response = s.get(url, headers=headers, cookies=cookies)
     self.soup = bs4.BeautifulSoup(response.text, 'lxml')