Exemplo n.º 1
0
def ecard_login(xh, pwd):
    '''一卡通登录'''
    url = 'http://yikatong.nepu.edu.cn/'
    try:
        session.get(url + 'homeLogin.action', headers=header)
        session.get(url + 'getCheckpic.action?rand=8888.197958871872',
                    headers=header)
        get_pass_url = 'http://yikatong.nepu.edu.cn/getpasswdPhoto.action'
        pw = session.get(get_pass_url, headers=header)
        im = Image.open(BytesIO(pw.content))
        new_pwd = get_pay_keyboard_number_location(im, pwd)
        # print(new_pwd)
        data = {
            "imageField.x": "37",
            "imageField.y": "10",
            'name': xh,
            'userType': '1',
            'passwd': new_pwd,
            'loginType': '2',
            'rand': '8888'
        }
        back_info = session.post(
            'http://yikatong.nepu.edu.cn/loginstudent.action',
            data=data,
            headers=header,
            timeout=(3.05, 5)).text
        if '登陆失败,密码错误' in back_info:
            return falseReturn(msg='登录失败,密码输入错误')
        elif '登陆失败,无此用户名称!' in back_info:
            return falseReturn(msg='登录失败,学号输入错误')
        else:
            return trueReturn()
    except:
        return falseReturn(msg='登录超时')
Exemplo n.º 2
0
def library_login(xh, pwd='0000'):
    '''图书馆登陆'''
    login_data = {'dztm': xh, 'dzmm': pwd}
    is_success = session.post('http://210.46.140.21:8080/opac/dzjsjg.jsp',
                              data=login_data)  #图书馆登陆
    if is_success.status_code == 200:
        is_success = is_success.text
        if 'success' in is_success:
            booke_info = session.get(
                'http://210.46.140.21:8080/opac/index_wdtsg.jsp').text
            soup = BeautifulSoup(booke_info, 'lxml')
            jiexi = soup.find_all('tr')
            xiangxi = []
            #print(jiexi[1])
            listname = [
                'id', 'bookid', 'bookname', 'author', 'juanqi',
                'guancangdanwei', 'diancangdi', 'canceleixing', 'jitime',
                'huantime', 'xujietime', 'xujiecishu', 'status'
            ]
            for i in jiexi[1]:
                c = i.find_all('tr')
                # print(c[1])
                for booke in c[1:]:
                    name = {}
                    booke_txt = booke.find_all('td', class_='bordertd')
                    #print(booke_txt[0].get_text()[:-1])
                    for i in range(13):
                        name[listname[i]] = booke_txt[i].get_text()[:-1]
                    xiangxi.append(name)
            print(xiangxi)
            backlist = []  #带有剩余过期时间的返回信息
            time = []
            for i in xiangxi:
                tss = i['huantime']
                date1 = datetime.datetime.strptime(tss, "%Y-%m-%d %H:%M:%S")
                date2 = datetime.datetime.now()
                num = (date1 - date2).days
                i['lastday'] = num
                backlist.append(i)
                if num <= 7:
                    time.append(time)
            # backlist.append({'total':len(xiangxi)})
            back_list = {
                'booklist': backlist,
                'total': len(xiangxi),
                'guoqi': len(time)
            }
            return trueReturn(data=back_list)
        elif '读者密码错误!请重新输入!' in is_success:
            print('读者密码错误!请重新输入!')
            return falseReturn(msg='密码错误')
        else:
            print('读者条码号不存在!请重新输入!')
            return falseReturn(msg='学号错误')
    else:
        return falseReturn(msg='系统暂时访问失败')
Exemplo n.º 3
0
def find_jwc_pwd():
    '''教务处密码找回'''
    url = 'http://jwgl.nepu.edu.cn/framework/enteraccount.jsp'
    data = {'account': '130101140323'}
    session = requests.session()
    # info=session.post(url,data).text

    data2 = {'account': '130101140323', 'sfzjh': '230622199407032050'}
    info = session.post('http://jwgl.nepu.edu.cn/yhxigl.do?method=resetPasswd',
                        data2)
    if info.status_code == 200:
        if '出错页面' in info.text:
            return falseReturn(msg='学号输入错误')
        elif '身份证件号输入错误或者你在系统中没有身份证号' in info.text:
            return falseReturn(msg='身份证号输入错误')
        else:
            print(info.text)
            return trueReturn(msg='密码已重置为身份证后六位')
    else:
        return falseReturn(msg='系统暂时无法访问,请稍后再试')
Exemplo n.º 4
0
def get_info_room(kc='0304', jsbh='00030'):
    '''查询教室占用情况'''  #还需要完善,暂时不启用
    zc = today_week()['zhou']
    kcsj = str(today_week()['week']) + kc
    if login1['status'] == False:
        return falseReturn(msg='暂时不能查询')
    else:
        login = login1['data']
        url = 'http://jwgl.nepu.edu.cn/jiaowu/kxjsgl/kxjsgl.do?method=goQueryjszyqk&xnxqh=2018-2019-2&jsbh='+jsbh+'&kcsj='+kcsj+'&typewhere=' \
               'xszq&startZc='+str(zc)+'&endZc='+str(zc)+'&startJc=&endJc=&startXq=1&endXq=1&jszt=&type=add'
        room_info = login.get(url).text
        soup = BeautifulSoup(room_info, 'lxml')
        tr = soup.find_all('tr')
        new_lb = []
        title = {
            "周次:": "zc",
            "教室状态:": "status",
            "教室:": "classroom",
            "时间标志:": "sjbz",
            "备注:": "text",
            "时间:": "time",
            "申 请 人:": "shenqingren",
            "课程:": "class"
        }
        for i in tr[2:3]:
            td = i.find_all('td')

            for i in td[1:]:
                new_lb.append(i.get_text('', '\r\n\t\t\t\t\t\t\t\t\t\t'))
        #print(new_lb)

        info = {}
        a = 0
        b = 2
        print(new_lb)
        for i in range(8):
            info[title[new_lb[a]]] = new_lb[b]
            a = a + 3
            b = b + 3
        print(info)
        return trueReturn(data=info)
Exemplo n.º 5
0
def get_tday_data(user_number):
    '''获取当日流水'''
    data = {
        "account": user_number,
        "inputObject": "all",
        "Submit": "+%C8%B7+%B6%A8+",
    }
    zhangdan = []
    te = session.post(
        "http://yikatong.nepu.edu.cn/accounttodatTrjnObject.action",
        data=data,
    ).text  # 当日流水
    exp = re.compile("&nbsp;&nbsp;.(\d{1,2}).*&nbsp.*\d")
    PageCount = int(exp.findall(te)[0])  # 总页面数
    print(PageCount)

    zhangdan = []
    for i in range(1, PageCount + 1):
        '''获取页面信息'''
        data = {'pageNum': str(i)}
        te = session.post(
            'http://yikatong.nepu.edu.cn/accounttodatTrjnObject.action',
            data=data,
            headers=header).text
        soup = BeautifulSoup(te, 'lxml')
        jixi = soup.find_all('tr', attrs={"class": re.compile("^listbg")})
        for i in jixi:
            td = i.find_all('td')
            info = {
                'time': td[0].string,
                'leixing': td[1].string,
                'zixitong': td[2].string,
                'dianzizhanghu': td[3].string,
                'jiaoyie': td[4].string,
                'yue': td[5].string,
                'cishu': td[6].string,
                'zhuangtai': td[7].string
            }
            zhangdan.append(info)  # 总消费记录
    return trueReturn(data=zhangdan)
Exemplo n.º 6
0
def get_ecard_info():
    '''获取用户信息、账号'''
    user_info = session.get(
        'http://yikatong.nepu.edu.cn/accountcardUser.action',
        headers=header).text
    soup = BeautifulSoup(user_info, 'lxml')
    te = soup.find_all('table')
    number = soup.find_all('div')
    user_number = number[4].string  #一卡通账号获取
    print(user_number)
    for i in te[1:2]:
        tr = i.find_all('td')
        te = tr[-5].string
    a = re.search('.+(卡)', te).group()
    b = re.search('(额).+(当)', te).group()
    c = re.search('(过渡余额).+(上)', te).group()
    yue = {
        'yue': a[:-2],
        'dangqianguoduyue': b[2:-2],
        'shangciguoduyue': c[5:-2],
    }
    # print(yue)
    return trueReturn(data=yue, msg=user_number)
Exemplo n.º 7
0
def login_jwc(username, pwd):
    '''教务处登陆'''
    code = login.get("http://jwgl.nepu.edu.cn/verifycode.servlet",
                     headers=header)
    if code.status_code == 200:
        im = Image.open(BytesIO(code.content))
        im = im.convert('L')
        yzm = get_validate_code_from_image(im)
        data = {'USERNAME': username, 'PASSWORD': pwd, 'RANDOMCODE': yzm}
        success = login.post('http://jwgl.nepu.edu.cn/Logon.do?method=logon',
                             data=data,
                             headers=header)

        if "验证码错误!!" in success.text:
            login_jwc()
        elif '该帐号不存在或密码错误,请联系管理员' in success.text:
            return falseReturn(msg='学号不存在或密码错误')
        else:
            login.get('http://jwgl.nepu.edu.cn/Logon.do?method=logonBySSO',
                      headers=header)
        return trueReturn(data=login)
    else:
        return falseReturn(msg='教务系统暂时无法访问')
Exemplo n.º 8
0
def get_month_bill(user_number):
    '''获取月账单'''
    ecard_post_data = {
        'account': user_number,
        'inputObject': 'all',
        'Submit': '+确+定+'
    }
    # print(ecard_post_data)
    get_usernumber = session.post(
        'http://yikatong.nepu.edu.cn/accounthisTrjn.action',
        data=ecard_post_data).text  #获取账号
    #print(get_usernumber)
    soup = BeautifulSoup(get_usernumber, 'lxml')
    adress = str(soup.find_all('form'))
    sc = re.search(r'"/accounthisTrjn.action[^\s]*', adress).group()  #获取账单查询地址
    post_url = 'http://yikatong.nepu.edu.cn' + sc[1:-1]
    post = session.post(post_url, data=ecard_post_data, headers=header).text
    soup2 = BeautifulSoup(post, 'lxml')
    adress2 = str(soup2.find_all('form'))
    sc = re.search(r'"/accounthisTrjn.action[^\s]*',
                   adress2).group()  # 获取日期提交地址
    post_url = 'http://yikatong.nepu.edu.cn' + sc[1:-1]
    ecard_post_time_data = {
        'inputStartDate': '20190301',
        'inputEndDate': '20190330'
    }
    te = session.post(post_url, data=ecard_post_time_data).text
    # print(te)
    #print(te)
    soup3 = BeautifulSoup(te, 'lxml')
    adress3 = str(soup3.find_all('form'))
    exp = re.compile('action="(.*)"\sid')
    url = exp.findall(str(adress3))[0]
    post_url2 = 'http://yikatong.nepu.edu.cn/accounthisTrjn.action' + url
    te = session.get(post_url2, headers=header).text
    exp = re.compile("&nbsp;&nbsp;.(\d{1,2}).*&nbsp.*\d")
    PageCount = int(exp.findall(te)[0])  #总页面数
    zhangdan = []
    for i in range(1, PageCount + 1):
        '''获取页面信息'''
        data = {'pageNum': str(i)}
        te = session.post(
            'http://yikatong.nepu.edu.cn/accountconsubBrows.action',
            data=data,
            headers=header).text
        soup = BeautifulSoup(te, 'lxml')
        jixi = soup.find_all('tr', attrs={"class": re.compile("^listbg")})
        for i in jixi:
            td = i.find_all('td')
            info = {
                'time': td[0].string,
                'leixing': td[1].string,
                'zixitong': td[2].string,
                'dianzizhanghu': td[3].string,
                'jiaoyie': td[4].string,
                'yue': td[5].string,
                'cishu': td[6].string,
                'zhuangtai': td[7].string
            }
            zhangdan.append(info)  # 总消费记录
    return trueReturn(data=zhangdan)
Exemplo n.º 9
0
def te():
    '''查询空教室'''

    if login1['status'] == False:
        return falseReturn(msg='暂时不能查询')
    else:
        login = login1['data']
        data = {
            'typewhere': 'xszq',
            'xnxqh': '2018-2019-2',
            'xqbh': '00001',
            'jxqbh': '',
            'jxlbh': '',
            'jsbh': '',
            'bjfh': '%3D',
            'rnrs': '',
            'jszt': '',
            'zc': zc,
            'zc2': zc,
            'xq': xq,
            'xq2': xq,
            'jc': '',
            'jc2': '',
        }
        back = login.post(
            'http://jwgl.nepu.edu.cn/jiaowu/kxjsgl/kxjsgl.do?method=queryKxxxByJs&typewhere=xszq',
            data=data).text
        soup = BeautifulSoup(back, 'lxml')
        table = soup.find_all('table')
        lb = []
        sj = ['', 'one', 'two', 'three', 'four', 'five', 'six']
        for i in table[:-3]:
            tr = i.find_all('tr')

            for i in tr[3:-2]:
                class_info = {}
                td = i.find_all('td')
                #print(td)
                jc = 0
                for i in td:
                    text = i.get_text()
                    # print(i.get_text('','\r\n\t\t\t\t\t\t\t\t'),jc)
                    if jc == 0:
                        try:
                            room_name = re.search(
                                '((1H-)|(2A-)|(1F-)|(主楼.))[0-9]+',
                                text).group()  #匹配教学楼
                            roomID = re.search('ue=.\w+', str(i)).group()
                            # print(roomID[4:])
                            # print(room_name)
                            class_info['room'] = room_name
                            class_info['roomID'] = roomID[4:]
                        except:
                            break
                    else:
                        jc_bh = sj[jc]  #上课时间转编号
                        if '◆' in text:
                            class_info[jc_bh] = 'sk'  #上课
                        elif 'J' in text:
                            class_info[jc_bh] = 'jy'  #借用
                        elif 'X' in text:
                            class_info[jc_bh] = 'sd'  #锁定
                        elif 'Κ' in text:
                            class_info[jc_bh] = 'ks'  #考试
                        elif 'G' in text:
                            class_info[jc_bh] = 'guding'  #固定调课
                        elif 'L' in text:
                            class_info[jc_bh] = 'linshi'  #临时调课
                        else:
                            class_info[jc_bh] = 'kx'  #空闲
                    jc = jc + 1
                if class_info:
                    lb.append(class_info)
                else:
                    pass
        return trueReturn(data=lb)
Exemplo n.º 10
0
def auth():
    xh = request.get_json()['studentid']
    pwd = request.get_json()['passwd']
    print(xh, pwd)
    if xh[2:4] == '80':  #判断是否是研究生
        login_info = get_login(xh, pwd)

        if login_info['msg'] != '100':
            return jsonify(login_info)
        else:
            type = '0'
            back_info = get_info(xh)
            score = get_score()
            kb = get_class()
            jw_status = '1'
            yjs_loginout()

    else:
        login = login_jwc(xh, pwd)
        if login['status'] == False:
            return jsonify(login)
        else:
            type = '1'
            login = login['data']
            back_info = info(login)
            score = socer(login)
            kb = get_kb(login, username=xh)
            jxjh = get_jxjh(login)
            # add_jw_info(studentid=xh,score=str(score),timetable=str(kb),plan=str(jxjh)) #存储
            logout()
            jw_status = '1'
    print(back_info)
    sfz = back_info['身份证']
    '''一卡通系统故障,暂时不提供'''
    if 'X' in sfz:
        ecard_pwd = sfz[-7:-2]  #一卡通密码获取
    else:
        ecard_pwd = sfz[-6:]
        '''一卡通系统验证'''
    name = ecard_login(xh, ecard_pwd)
    if name['status'] == True:
        '''一卡通登录成功'''
        try:
            ecard_pwd = ecard_pwd
            ecard_ID = get_ecard_info()
            ecard_ye = ecard_ID['data']
            ecard_ID = str(ecard_ID['msg'])
            month_bill = get_month_bill(ecard_ID)
            day_bill = get_tday_data(ecard_ID)
            loginout()
            ecard_status = '1'
            back_ecard = {
                'yue': ecard_ye,
                'month_bill': month_bill['data'],
                'day_bill': day_bill['data']
            },
        except:
            ecard_status = '0'
            ecard_ye = ''
            back_ecard = {},
    else:
        ecard_pwd = None
        ecard_status = '0'
        ecard_ye = ''
        back_ecard = {},
    library_login_info = library_login(xh)
    if library_login_info['status'] == True:
        library_pwd = '0000'
        library_status = '1'
    else:
        library_pwd = None
        library_status = '0'
    #add_jw_pwd(studentid=xh,jw_pwd=pwd,library_pwd=library_pwd,ecard_pwd=ecard_pwd,info=str(back_info),type_info=type,IDnumber=sfz)
    status = {
        'jw_status': jw_status,
        'library_status': library_status,
        'ecard_status': ecard_status
    }
    token = create_token(xh, status)
    back_info = {
        "jw": {
            "kb": kb,
            "score": score,
        },
        'library': library_login_info['data'],
        'ecard': back_ecard,
        'header': str(token, encoding='utf-8'),
        'library_status': library_status,
        'ecard_status': ecard_status,
        'jw_status': "1"
    }
    # with open('{}.json'.format(xh),'wb') as f:
    #     f.write(json.dumps(back_info))
    print(back_info)

    return jsonify(trueReturn(data=back_info))