Ejemplo n.º 1
0
def get_score(username, password):
    reg = r'<font color="red">请先登录系统</font>'
    session = login(username, password)
    response = session.get('http://jwgl.just.edu.cn:8080/jsxsd/kscj/cjcx_list')
    if re.findall(reg, response.text):
        response_info.error(static.JUST_ACCOUNT_LOGIN_ERROR, '用户名或密码错误', '')
    else:
        th_list = [
            'order_num', 'start_semester', 'course_num', 'course_name',
            'score', 'credit', 'total_hours', 'examination_method',
            'course_attribute', 'course_nature', 'alternative_course_number',
            'alternative_course_name', 'mark_of_score'
        ]
        data_list = []
        soup = BeautifulSoup(response.text, "html.parser")
        trs = soup.find_all("tr")[2:]
        is_pingjia = soup.find("table", id='dataList')
        if trs:
            if is_pingjia:  # 判断是否评价
                for tr in trs:
                    tds = tr.find_all("td")
                    i = 0
                    data = {}
                    for td in tds:
                        data[th_list[i]] = td.get_text()
                        i = i + 1
                    data_list.append(data)
                data_list = response_info.success('成绩查询成功', data_list)
                print("成绩查询 " + username)
        return data_list
Ejemplo n.º 2
0
def get_grade_point(username, password):
    reg = r'<font color="red">请先登录系统</font>'
    session = login(username, password)
    response = session.get('http://jwgl.just.edu.cn:8080/jsxsd/kscj/cjcx_list')
    if re.findall(reg, response.text):
        return response_info.error(static.JUST_ACCOUNT_LOGIN_ERROR, '用户名或密码错误',
                                   '')
    else:
        p = point.Point()
        data = get_score(username, password)
        try:
            if len(data['info']) > 1:
                sum_point = p.get_average_point(data['info'])
                each_list = p.get_each_point(data['info'])
                each_list.insert(0, {'year': 'all', 'point': str(sum_point)})
                # 数据库操作
                result = db_util.get_student_jidian(username)
                each_list = response_info.success('绩点查询成功', each_list)
                if result == 0:
                    jidian = ''
                    for item in each_list['info']:
                        jidian += item['year'] + ':' + item['point'] + '&'
                    db_util.add_student_jidian(jidian, username)
                else:
                    jidian = ''
                    for item in each_list['info']:
                        jidian += item['year'] + ':' + item['point'] + '&'
                    db_util.update_student_jidian(jidian, username)
            else:
                each_list = response_info.error(static.JUST_NO_SCORE, '没有成绩')
        except Exception as e:
            each_list = response_info.error(500, '教务系统异常', "")
            raise

        return each_list
Ejemplo n.º 3
0
def vpnInfo(username, password):
    session, vpn_account = login(username, password)
    data_list = []
    try:
        response = session.get(
            'https://vpn.just.edu.cn/jsxsd/grxx/,DanaInfo=jwgl.just.edu.cn,Port=8080+xsxx',
            headers=headers,
            verify=False)
        soup = BeautifulSoup(response.text, "html.parser")
        isVpnLoginSuccess = soup.find('span', class_='cssLarge')
        isAccountLoginSuccess = soup.find('div', class_='dlti')
        if not isVpnLoginSuccess:
            if not isAccountLoginSuccess:
                temp = []
                trs = soup.select("#xjkpTable tr")
                name = "".join((trs[3].select('td')[1].get_text()).split())
                birthday = "".join((trs[4].select('td')[1].get_text()).split())
                tds = trs[2].select('td')
                for td in tds:
                    temp.append(td.get_text()[3:])
                data_list = {
                    "academy": temp[0],
                    "major": temp[1],
                    "class_num": temp[3],
                    "name": name,
                    "birthday": birthday,
                    'username': username,
                    'password': password
                }
                data_list = response_info.success('个人信息查询成功', data_list)
                result = db_util.get_student_info(username)
                if result == 0:
                    db_util.add_student_info(
                        username, md5(password), name, birthday, temp[1],
                        temp[0], temp[3],
                        datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                        datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
                else:
                    db_util.update_student_info(
                        password, name, birthday, temp[1], temp[0], temp[3],
                        username,
                        datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
            else:
                data_list = response_info.error(
                    static.JUST_ACCOUNT_LOGIN_ERROR, '教务系统账号或密码错误', '')
        else:
            data_list = response_info.error(static.JUST_VPN_LOGIN_ERROR,
                                            'vpn账号被占用', vpn_account)
    except Exception as e:
        logging.exception(e)
        r.rpush("vpn_account", vpn_account)
        raise
    finally:
        session.post('https://vpn.just.edu.cn/dana-na/auth/logout.cgi',
                     headers=headers,
                     verify=False)
    return data_list, vpn_account
Ejemplo n.º 4
0
def vpnScore(username, password):
    session, vpn_account = login(username, password)
    try:
        response = session.get(
            'https://vpn.just.edu.cn/jsxsd/kscj/,DanaInfo=jwgl.just.edu.cn,Port=8080+cjcx_list',
            headers=headers,
            verify=False)

        data_list = []
        th_list = [
            'order_num', 'start_semester', 'course_num', 'course_name',
            'score', 'credit', 'total_hours', 'examination_method',
            'course_attribute', 'course_nature', 'alternative_course_number',
            'alternative_course_name', 'mark_of_score'
        ]
        soup = BeautifulSoup(response.text, "html.parser")
        isVpnLoginSuccess = soup.find('span', class_='cssLarge')
        isAccountLoginSuccess = soup.find('div', class_='dlti')
        if not isVpnLoginSuccess:
            if not isAccountLoginSuccess:
                trs = soup.find_all("tr")[2:]
                is_pingjia = soup.find("table", id='dataList')
                if trs:
                    if is_pingjia:  # 判断是否评价
                        for tr in trs:
                            tds = tr.find_all("td")
                            i = 0
                            data = {}
                            for td in tds:
                                data[th_list[i]] = td.get_text()
                                i = i + 1
                            data_list.append(data)
                        data_list = response_info.success('成绩查询成功', data_list)
                        print("成绩查询 " + username)
                    else:
                        data_list = response_info.error(
                            static.JUST_NO_EVALUATE, '未评价', '')
                else:
                    data_list = response_info.error(static.JUST_NO_SCORE,
                                                    '没有成绩', '')
            else:
                data_list = response_info.error(
                    static.JUST_ACCOUNT_LOGIN_ERROR, '教务系统账号或密码错误', '')
        else:
            data_list = response_info.error(static.JUST_VPN_LOGIN_ERROR,
                                            'vpn账号被占用', vpn_account)
    except Exception as e:
        logging.exception(e)
        r.rpush("vpn_account", vpn_account)
        raise
    finally:
        session.post('https://vpn.just.edu.cn/dana-na/auth/logout.cgi',
                     headers=headers,
                     verify=False)
    return data_list, vpn_account
Ejemplo n.º 5
0
def getSport(username, password):
    session = requests.session()
    data_list = []
    try:
        sport_data = {
            'chkuser': '******',
            'username': username,
            'password': password
        }
        session.post(
            'https://vpn.just.edu.cn/,DanaInfo=202.195.195.147+index1.asp',
            headers=headers,
            data=sport_data,
            verify=False)
        response = session.get(
            'https://vpn.just.edu.cn/zcgl/,DanaInfo=202.195.195.147+xskwcx.asp?action=zccx',
            headers=headers,
            verify=False)
        response.encoding = 'gb2312'

        form_list = []
        info = {}
        soup = BeautifulSoup(response.text, 'html.parser')

        title = soup.find('p', attrs={'align': 'center'})
        isSportAccountLoginSuccess = title.find('font', attrs={'size': '3'})
        if not isSportAccountLoginSuccess:
            title = soup.find('p', attrs={'align': 'center'})
            name = title.find('font', attrs={'size': '6'}).text
            info['name'] = name
            year = title.find('font', attrs={'size': '4'}).text
            info['year'] = year
            form = soup.find('form')
            trs = form.find_all('tr')
            for tr in trs[1:-1]:
                data = {}
                tds = tr.find_all('td')
                data['number'] = tds[0].text
                data['date'] = tds[1].text
                data['time'] = tds[2].text
                form_list.append(data)
            total = trs[-1].text
            info['total'] = total
            data_list.append(info)
            data_list.append(form_list)
            data_list = response_info.success("早操查询成功", data_list)
        else:
            data_list = response_info.error(static.JUST_SPORT_ACCOUNT_ERROR,
                                            '体育学院密码错误', '')

    except Exception as e:
        data_list = response_info.error(500, '教务系统异常', "")
        raise
    return data_list
Ejemplo n.º 6
0
 def getHotBook(self):
     p = Proxy()
     session, vpn_account = p.login()
     try:
         result = session.get(
             'https://vpn.just.edu.cn/opac/,DanaInfo=lib.just.edu.cn,Port=8080+top100.php',
             headers={
                 'User-Agent':
                 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
                 'Origin': 'https://vpn.just.edu.cn',
                 'Upgrade-Insecure-Requests': '1'
             },
             verify=False)
         result.encoding = 'utf-8'
         #print (result.text)
         soup = BeautifulSoup(result.content, 'html.parser')
         isVpnLoginSuccess = soup.find('span', class_='cssLarge')
         isAccountLoginSuccess = soup.find('div', class_='dlti')
         hot_borrow_li = soup.find_all('td')
         hot_borrow_name = []
         hot_borrow_url = []
         hot_books_name = []
         hot_books_url = []
         if not isVpnLoginSuccess:
             if not isAccountLoginSuccess:
                 for li in hot_borrow_li[0:10]:
                     hot_borrow_name.append(li.text)
                 self.data_list.append(hot_borrow_name)
                 self.data_list = response_info.success(
                     "热门搜索词查询成功", self.data_list)
             else:
                 self.data_list = response_info.error(
                     static.JUST_ACCOUNT_LOGIN_ERROR, '教务系统账号错误', '')
         else:
             self.data_list = response_info.error(
                 static.JUST_VPN_LOGIN_ERROR, 'vpn账号被占用', vpn_account)
     except:
         r.rpush("vpn_account", vpn_account)
         raise
     finally:
         session.post(
             'https://vpn.just.edu.cn/dana-na/auth/logout.cgi',
             headers={
                 'User-Agent':
                 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
                 'Origin': 'https://vpn.just.edu.cn',
                 'Upgrade-Insecure-Requests': '1'
             },
             verify=False)
     return self.data_list, vpn_account
Ejemplo n.º 7
0
def get_all_kb(username, password, semester):
    session, vpn_account = login(username, password)
    data_list = []
    try:
        url = "https://vpn.just.edu.cn/jsxsd/xskb/,DanaInfo=jwgl.just.edu.cn,Port=8080+xskb_list.do"
        paramrs = {'zc': '', 'xnxq01id': semester}
        response = session.get(url, params=paramrs)
        response.encoding = 'utf-8'
        soup = BeautifulSoup(response.text, "html.parser")
        isVpnLoginSuccess = soup.find('span', class_='cssLarge')
        isAccountLoginSuccess = soup.find('div', class_='dlti')
        isWeiPingJia = False
        if not isVpnLoginSuccess:
            if not isAccountLoginSuccess:
                week_list = [
                    'monday', 'tuesday', 'wednesday', 'thursday', 'friday',
                    'saturday', 'sunday'
                ]
                trs = soup.select("#kbtable tr")
                data_list = []

                for tr in trs[1:]:

                    data = {}
                    for i, td in enumerate(tr.select(".kbcontent")):
                        data[week_list[i]] = StringUtilALl(td)
                    data_list.append(data)

                if isWeiPingJia:
                    data_list = response_info.error(static.JUST_NO_EVALUATE,
                                                    '未评价', '')
                else:
                    data_list = response_info.success("所有课表查询成功", data_list)
            else:
                data_list = response_info.error(
                    static.JUST_ACCOUNT_LOGIN_ERROR, '教务系统账号或密码错误', '')
        else:
            data_list = response_info.error(static.JUST_VPN_LOGIN_ERROR,
                                            'vpn账号被占用', vpn_account)
    except Exception as e:
        logging.exception(e)
        r.rpush("vpn_account", vpn_account)
        raise
    finally:
        session.post('https://vpn.just.edu.cn/dana-na/auth/logout.cgi',
                     headers=headers,
                     verify=False)
    print("课表查询" + username + ' ' + semester)
    print(data_list)
    return data_list, vpn_account
Ejemplo n.º 8
0
def get_download_apk_info():
    db = pymysql.Connect(
        host='localhost',
        port=3306,
        user='******',
        passwd=db_password,
        db='just',
        charset='utf8'
    )
    cursor = db.cursor()
    sql="select *   from   apk   order   by   id   desc   limit   1 "
    data = {}
    try:
        cursor.execute(sql)
        result= cursor.fetchone()
        i=0
        for item in cursor.description:
            data[item[0]]=result[i]
            i+=1
        return response_info.success('apk信息查询成功',data)

    except Exception as e:
        logging.exception(e)
        return response_info.error(static.JUST_APK_SELECT_ERROR,'apk信息查询失败', data)
    # 关闭数据库连接
    finally:
        db.close()
Ejemplo n.º 9
0
def update_download_apk_info(download_info):
    db = pymysql.Connect(host='localhost',
                         port=3306,
                         user='******',
                         passwd=db_password,
                         db='just',
                         charset='utf8')
    cursor = db.cursor()
    sql = "insert into apk(appname,serverVersion,serverFlag,lastForce,updateurl,updateinfo) values(%s,%s,%s,%s,%s,%s)"
    try:
        cursor.execute(sql, (
            download_info['appname'],
            download_info['serverVersion'],
            download_info['serverFlag'],
            download_info['lastForce'],
            'http://120.25.88.41/apk/download/guohe',
            download_info['updateinfo'],
        ))
        db.commit()
        return response_info.success('更新成功', download_info)
    except Exception as e:
        logging.exception(e)
        db.rollback()
        return response_info.error(static.JUST_APK_INFO_UPDATE_ERROR, '更新失败',
                                   download_info)

    finally:
        db.close()
Ejemplo n.º 10
0
def update_download_apk_info(download_info):
    db = pymysql.Connect(host='106.14.220.63',
                         port=3306,
                         user='******',
                         passwd='root',
                         db='guohe_home',
                         charset='utf8')
    cursor = db.cursor()
    sql = "insert into apk(appname,serverVersion,serverFlag,lastForce,updateurl,updateinfo) values(%s,%s,%s,%s,%s,%s)"
    try:
        cursor.execute(sql, (
            download_info['appname'],
            download_info['serverVersion'],
            download_info['serverFlag'],
            download_info['lastForce'],
            'http://106.14.220.63/apk/download/guohe',
            download_info['updateinfo'],
        ))
        db.commit()

        return response_info.success('更新成功', download_info)
    except:
        db.rollback()

        return response_info.error(802, '更新失败', download_info)

    finally:
        db.close()
Ejemplo n.º 11
0
def get_carousel_by_quantity(quantity):
    db = pymysql.Connect(
        host='120.25.88.41',
        port=3306,
        user='******',
        passwd='935377012',
        db='just',
        charset='utf8'
    )
    cursor = db.cursor()
    sql = "select title,img,url,describe_txt   from   carousel   order   by   id   desc   limit  %s  " % quantity

    try:
        cursor.execute(sql)
        result=cursor.fetchall()
        datalist=[]
        for tem in result:
            format_t={}
            format_t["title"] = tem[0]
            format_t["img"] = tem[1]
            format_t["url"] = tem[2]
            format_t["describe"] = tem[3]
            datalist.append(format_t)
        return response_info.success("获取轮播图成功",datalist)
    except:
        return response_info.error("2","获取轮播图失败",datalist)

    finally:
        db.close()
Ejemplo n.º 12
0
def get_advertisement():
    db = pymysql.Connect(
        host='120.25.88.41',
        port=3306,
        user='******',
        passwd='935377012',
        db='just',
        charset='utf8'
    )
    cursor = db.cursor()
    sql = "select title,img,url,describe_txt   from   advertisement   order   by   id   desc   limit  1  "

    try:
        cursor.execute(sql)
        result = cursor.fetchone()
        format_t = {}
        format_t["title"] = result[0]
        format_t["img"] = result[1]
        format_t["url"] = result[2]
        format_t["describe"] = result[3]

        return response_info.success("获取广告图成功", format_t)
    except:
        return response_info.error("2","获取广告图失败", format_t)

    finally:
        db.close()
Ejemplo n.º 13
0
def add_feedback(name,content,category,contact):
    db = pymysql.Connect(
        host='localhost',
        port=3306,
        user='******',
        passwd=db_password,
        db='just',
        charset='utf8'
    )
    dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    cursor = db.cursor()
    print("保存反馈信息")
    sql = "insert into feedback(f_name,f_time,f_content,f_category,f_contact) values ('%s','%s','%s','%s','%s')" % \
          (name,dt,content,category,contact)
    try:
        # 执行sql语句
        cursor.execute(sql)
        # 提交到数据库执行
        db.commit()
        return response_info.success('反馈成功',name)
    except Exception as e:
        logging.exception(e)
        db.rollback()
        return response_info.error(static.FEEDBACK_ERROR,'反馈失败', e)
    finally:
        # 关闭数据库连接
        db.close()
Ejemplo n.º 14
0
def vpnKebiao(username, password, semester):
    session, vpn_account = login(username, password)
    data_list = []
    try:
        url = "https://vpn.just.edu.cn/jsxsd/xskb/,DanaInfo=jwgl.just.edu.cn,Port=8080+xskb_list.do"
        paramrs = {'zc': '1', 'xnxq01id': semester}
        response = session.get(url, params=paramrs)
        response.encoding = 'utf-8'
        soup = BeautifulSoup(response.text, "html.parser")
        isVpnLoginSuccess = soup.find('span', class_='cssLarge')
        isAccountLoginSuccess = soup.find('div', class_='dlti')
        isWeiPingJia = False
        if not isVpnLoginSuccess:
            if not isAccountLoginSuccess:
                weeks = soup.select("#zc option")
                week_list = []
                for week in weeks:
                    week_list.append(week.attrs['value'])
                for item in week_list[1:21]:
                    data = kebiaoUtil(session, item, semester)
                    if data == '未评价':
                        isWeiPingJia = True
                    else:
                        data_list.append({semester + '_' + item: data})
                        # db_util.add_kb(semester + '_' + item,data)
                if isWeiPingJia:
                    data_list = response_info.error(static.JUST_NO_EVALUATE,
                                                    '未评价', '')
                else:
                    data_list = response_info.success("所有课表查询成功", data_list)
            else:
                data_list = response_info.error(
                    static.JUST_ACCOUNT_LOGIN_ERROR, '教务系统账号或密码错误', '')
        else:
            data_list = response_info.error(static.JUST_VPN_LOGIN_ERROR,
                                            'vpn账号被占用', vpn_account)
    except Exception as e:
        logging.exception(e)
        r.rpush("vpn_account", vpn_account)
        raise
    finally:
        session.post('https://vpn.just.edu.cn/dana-na/auth/logout.cgi',
                     headers=headers,
                     verify=False)
    print("课表查询" + username + ' ' + semester)
    return data_list, vpn_account
Ejemplo n.º 15
0
def get_student_info(username, password):
    reg = r'<font color="red">请先登录系统</font>'
    session = login(username, password)
    response = session.get(
        'http://jwgl.just.edu.cn:8080/jsxsd/grxx/xsxx?Ves632DSdyV=NEW_XSD_XJCJ'
    )
    data_list = []
    if re.findall(reg, response.text):
        return response_info.error(static.JUST_ACCOUNT_LOGIN_ERROR, '用户名或密码错误',
                                   '')
    else:
        try:
            soup = BeautifulSoup(response.text, "html.parser")
            temp = []
            trs = soup.select("#xjkpTable tr")
            name = "".join((trs[3].select('td')[1].get_text()).split())
            birthday = "".join((trs[4].select('td')[1].get_text()).split())
            tds = trs[2].select('td')
            for td in tds:
                temp.append(td.get_text()[3:])
            data_list = {
                "academy": temp[0],
                "major": temp[1],
                "class_num": temp[3],
                "name": name,
                "birthday": birthday,
                'username': username,
                'password': password
            }
            data_list = response_info.success('个人信息查询成功', data_list)
            result = db_util.get_student_info(username)
            if result == 0:
                db_util.add_student_info(
                    username, md5(password), name, birthday, temp[1], temp[0],
                    temp[3],
                    datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                    datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
            else:
                db_util.update_student_info(
                    password, name, birthday, temp[1], temp[0], temp[3],
                    username,
                    datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
        except:
            data_list = response_info.error(500, '教务系统异常', "")
        return data_list
Ejemplo n.º 16
0
def upload():
    f = request.files['file']
    fname=secure_filename(f.filename)
    if allowed_file(fname):
        upload_path = os.path.join(r'/var/www/apk',secure_filename(f.filename))  #注意:没有的文件夹一定要先创建,不然会提示没有该路径
        f.save(upload_path)
        print(secure_filename(f.filename))
        token = base64.b64encode(secure_filename(f.filename).encode('utf-8'))
        return jsonify(response_info.success('上传成功',str(token)))
    else:
        return jsonify(response_info.error('801','文件类型不符合要求',''))
Ejemplo n.º 17
0
def get_kb(username, password, semester):
    reg = r'<font color="red">请先登录系统</font>'
    session = login(username, password)
    response = session.get(
        'http://jwgl.just.edu.cn:8080/jsxsd/xskb/xskb_list.do')
    data_list = []
    if re.findall(reg, response.text):
        return response_info.error(static.JUST_ACCOUNT_LOGIN_ERROR, '用户名或密码错误',
                                   '')
    else:
        try:
            url = "http://jwgl.just.edu.cn:8080/jsxsd/xskb/xskb_list.do"
            paramrs = {'zc': '1', 'xnxq01id': semester}
            response = session.get(url, params=paramrs)
            response.encoding = 'utf-8'
            soup = BeautifulSoup(response.text, "html.parser")
            isWeiPingJia = False
            weeks = soup.select("#zc option")
            week_list = []
            for week in weeks:
                week_list.append(week.attrs['value'])
            for item in week_list[1:26]:
                data = kebiaoUtil(session, item, semester)

                if data == '未评价':
                    isWeiPingJia = True
                else:
                    data_list.append({semester + '_' + item: data})
            if isWeiPingJia:
                data_list = response_info.error(static.JUST_NO_EVALUATE, '未评价',
                                                '')
            else:
                data_list = response_info.success("所有课表查询成功", data_list)
        except:

            data_list = response_info.error(500, '教务系统异常', "")
            raise
        return data_list
Ejemplo n.º 18
0
def get_pxc_users():
    db = pymysql.Connect(host='120.25.88.41',
                         port=3306,
                         user='******',
                         passwd='935377012',
                         db='just',
                         charset='utf8')
    cursor = db.cursor()
    sql = "select count(*) from student"
    try:
        cursor.execute(sql)
        numUsers = cursor.fetchone()
        return numUsers
    except:
        raise
        return response_info.error('1006', '用户数查询失败', data)
    finally:
        db.close()
Ejemplo n.º 19
0
def get_toast_info():
    db = pymysql.Connect(host='106.14.220.63',
                         port=3306,
                         user='******',
                         passwd='root',
                         db='guohe_home',
                         charset='utf8')
    cursor = db.cursor()
    sql = "select content   from   guohe_lite_toast   order   by   id   desc   limit   1 "
    try:
        cursor.execute(sql)
        result = cursor.fetchone()
        return response_info.success('小程序通知查询成功', result)
    except:
        return response_info.error('2', '小程序通知查询失败', result)
        # 关闭数据库连接
    finally:
        db.close()
Ejemplo n.º 20
0
def add_advertisement(title,img,url,describe_txt):
    db = pymysql.Connect(
        host='120.25.88.41',
        port=3306,
        user='******',
        passwd='935377012',
        db='just',
        charset='utf8'
    )
    cursor=db.cursor()
    sql="insert into advertisement (title,img,url,describe_txt) VALUES (%s,%s,%s,%s)"
    try:
        cursor.execute(sql,(title,img,url,describe_txt))
        db.commit()
        return response_info.success("增加广告图成功",(title,img,url,describe_txt))
    except:
        return response_info.error("2","增加广告失败",(title,img,url,describe_txt))
    finally:
        db.close()
Ejemplo n.º 21
0
def set_clicks_web(numOfclicks_web):
    db = db = pymysql.Connect(host='106.14.220.63',
                              port=3306,
                              user='******',
                              passwd='root',
                              db='guohe_home',
                              charset='utf8')
    cursor = db.cursor()
    sql = "update guohe_data set clicks_web=%s where id=1"
    try:
        cursor.execute(sql, numOfclicks_web)
        db.commit()
        return response_info.success('Web点击量更新成功', numOfclicks_web)
    except:
        db.rollback()

        return response_info.error('1005', 'Web点击量更新失败', numOfclicks_web)
    finally:
        db.close()
Ejemplo n.º 22
0
def update_toast(toast_update_info):
    db = pymysql.Connect(host='106.14.220.63',
                         port=3306,
                         user='******',
                         passwd='root',
                         db='guohe_home',
                         charset='utf8')
    cursor = db.cursor()
    sql = "insert into guohe_lite_toast(content,update_time) values(%s,%s) "
    try:
        dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        cursor.execute(sql, (toast_update_info, dt))
        db.commit()
        return response_info.success('通知更新成功', toast_update_info)
    except:
        db.rollback()
        return response_info.error(1, '更新失败', toast_update_info)
    finally:
        db.close()
Ejemplo n.º 23
0
def set_downloads(numOfdownloads):
    db = db = pymysql.Connect(host='106.14.220.63',
                              port=3306,
                              user='******',
                              passwd=static.DB_PASSWORD2,
                              db='guohe_home',
                              charset='utf8')
    cursor = db.cursor()
    sql = "update guohe_data set downloads=%s where id=1"
    try:
        cursor.execute(sql, numOfdownloads)
        db.commit()
        return response_info.success('下载量更新成功', numOfdownloads)
    except:
        db.rollback()

        return response_info.error('1003', '下载量更新失败', numOfdownloads)
    finally:
        db.close()
Ejemplo n.º 24
0
def add_vpn_info(username, password):
    r = redis.Redis(host='127.0.0.1', port=6379, db=0)
    vpn_list = r.lrange('vpn_account', 0, -1)
    flag = True
    try:
        for i, item in enumerate(vpn_list):
            data = eval(item)
            if data['username'] == username:
                flag = False
        if flag:
            r.rpush('vpn_account', {
                'username': username,
                'password': password
            })
            return response_info.success('vpn账号添加成功', username)
        else:
            return response_info.error(static.JUST_HAS_VPN_ACCOUNT,
                                       'vpn账号已经存在', '')
    except:
        raise
Ejemplo n.º 25
0
def update_student_jidian(jidian,username):
    db = pymysql.Connect(
        host='localhost',
        port=3306,
        user='******',
        passwd=db_password,
        db='just',
        charset='utf8'
    )
    cursor = db.cursor()
    print("更新数据")
    sql = "update jidian set jidian='%s' where username='******'" % (jidian, username)
    try:
        cursor.execute(sql)
        db.commit()
    except Exception as e:
        logging.exception(e)
        db.rollback()
        return response_info.error(static.JUST_APK_INFO_UPDATE_ERROR, '更新失败', username)
    finally:
        db.close()
Ejemplo n.º 26
0
def get_data():
    db = db = pymysql.Connect(host='106.14.220.63',
                              port=3306,
                              user='******',
                              passwd='root',
                              db='guohe_home',
                              charset='utf8')
    cursor = db.cursor()
    sql = "select * from guohe_data "
    data = {}
    try:
        cursor.execute(sql)
        result = cursor.fetchone()
        i = 0
        for item in cursor.description:
            data[item[0]] = result[i]
            i += 1
        return data
    except:
        return response_info.error('1001', '网站基本数据查询失败', data)
    finally:
        db.close()
Ejemplo n.º 27
0
def get_xiaoli():
    url = 'http://jwc.just.edu.cn/'
    data = {}
    try:
        # response = requests.get(url, headers=headers, verify=False)
        # soup = BeautifulSoup(response.text, "html.parser")
        #
        # year = "".join(soup.find('p', class_='da').get_text().split())[:11]
        # currentTab = "".join(soup.find('p', class_='da').get_text().split())[11:]
        # index = soup.find('span', class_='shuzi').get_text()

        data['year'] = "2017-2018-2"
        tab = datetime.datetime.now().isocalendar()[2]

        currentTab = ''
        if tab == 1:
            currentTab = '星期一'
        if tab == 2:
            currentTab = '星期二'
        if tab == 3:
            currentTab = '星期三'
        if tab == 4:
            currentTab = '星期四'
        if tab == 5:
            currentTab = '星期五'
        if tab == 6:
            currentTab = '星期六'
        if tab == 7:
            currentTab = '星期日'
        data['currentTab'] = currentTab
        data['index'] = (datetime.datetime.now().isocalendar()[1] - 8) % 25
        data = response_info.success("校历查询成功", data)
    except Exception as e:

        data = response_info.error(500, '教务系统异常', "")
        raise
    return data
Ejemplo n.º 28
0
def get_download_apk_info():
    db = pymysql.Connect(host='106.14.220.63',
                         port=3306,
                         user='******',
                         passwd='root',
                         db='guohe_home',
                         charset='utf8')
    cursor = db.cursor()
    sql = "select *   from   apk   order   by   id   desc   limit   1 "
    data = {}
    try:
        cursor.execute(sql)
        result = cursor.fetchone()
        i = 0
        for item in cursor.description:
            data[item[0]] = result[i]
            i += 1
        return response_info.success('apk信息查询成功', data)

    except:
        return response_info.error('701', 'apk信息查询失败', data)
    # 关闭数据库连接
    finally:
        db.close()
Ejemplo n.º 29
0
def VpnGetSport(username, password):
    lock.acquire()
    session = requests.session()
    vpn_account = {}
    try:
        flag = True
        while flag:
            time.sleep(0.5)
            if r.lrange('vpn_account', 0, -1):  # 若缓存中没有账号则等待
                flag = False
                vpn_account = eval(r.lpop('vpn_account'))
                url = "https://vpn.just.edu.cn/dana-na/auth/url_default/login.cgi"
                data = {
                    'tz_offset': '480',
                    'username': vpn_account['username'],
                    'password': vpn_account['password'],
                    'realm': 'LDAP-REALM',
                    'btnSubmit': '登录'
                }
                cookies = {
                    'lastRealm': 'LDAP-REALM',
                    'DSSIGNIN': 'url_default',
                    'WWHTJIKTLSN_Impl': 'javascript',
                    'DSLastAccess': '1510459958'
                }
                session.post(url=url,
                             data=data,
                             cookies=cookies,
                             headers=headers,
                             verify=False)

        sport_data = {
            'chkuser': '******',
            'username': username,
            'password': password
        }
        session.get('https://vpn.just.edu.cn/,DanaInfo=tyb.just.edu.cn+',
                    headers=headers,
                    verify=False)
        session.post(
            'https://vpn.just.edu.cn/,DanaInfo=202.195.195.147+index1.asp',
            headers=headers,
            data=sport_data,
            verify=False)
        response = session.get(
            'https://vpn.just.edu.cn/zcgl/,DanaInfo=202.195.195.147+xskwcx.asp?action=jlbcx',
            headers=headers,
            verify=False)
        response.encoding = 'gb2312'
        data_list = []
        form_list = []
        info = {}
        soup = BeautifulSoup(response.text, 'html.parser')
        isVpnLoginSuccess = soup.find('span', class_='cssLarge')
        if not isVpnLoginSuccess:
            title = soup.find('p', attrs={'align': 'center'})
            isSportAccountLoginSuccess = title.find('font',
                                                    attrs={'size': '3'})
            if not isSportAccountLoginSuccess:
                name = title.find('font', attrs={'size': '6'}).text
                info['name'] = name
                year = title.find('font', attrs={'size': '4'}).text
                info['year'] = year
                form = soup.find('form')
                trs = form.find_all('tr')
                for tr in trs[1:-1]:
                    data = {}
                    tds = tr.find_all('td')
                    data['number'] = tds[0].text
                    if len(tds[1].text.split(" ")) > 2:
                        data['date'] = tds[1].text.split(" ")[0] + tds[1].text.split(" ")[1] + " " + \
                                       tds[1].text.split(" ")[2]
                    else:
                        data['date'] = tds[1].text
                    data['time'] = tds[2].text
                    form_list.append(data)
                total = trs[-1].text
                temp = ''
                for item in total.split("\r\n")[1:]:
                    temp = temp + item.strip() + '\r\n'
                info['total'] = temp
                info['sum'] = total.split("\r\n")[0]
                data_list.append(info)
                data_list.append(form_list)
                data_list = response_info.success("俱乐部查询成功", data_list)
            elif isSportAccountLoginSuccess.string == "很抱歉,数据库中没有相关信息!":
                data_list = response_info.error(static.JUST_SPORT_NO_DATA,
                                                '很抱歉,数据库中没有相关信息!', '')

            else:
                data_list = response_info.error(
                    static.JUST_SPORT_ACCOUNT_ERROR, '体育学院密码错误', '')
        else:
            data_list = response_info.error(static.JUST_VPN_LOGIN_ERROR,
                                            'vpn账号被占用', vpn_account)
    except Exception as e:
        logging.exception(e)
        r.rpush("vpn_account", vpn_account)
        raise
    finally:
        session.post('https://vpn.just.edu.cn/dana-na/auth/logout.cgi',
                     headers=headers,
                     verify=False)
        lock.release()
    return data_list, vpn_account
Ejemplo n.º 30
0
def vpnGetClassrooms(username, password, school_year, area_id, building_id,
                     zc1):
    session, vpn_account = login(username, password)
    try:
        zc2 = int(zc1) + 1
        str_zc2 = str(zc2)
        classroom_data = {
            'xnxqh': school_year,
            'skyx': '',
            'xqid': area_id,
            'jzwid': building_id,
            'zc1': zc1,
            'zc2': str_zc2,
            'jc1': '',
            'jc2': ''
        }
        response = session.post(
            'https://vpn.just.edu.cn/jsxsd/kbcx/,DanaInfo=jwgl.just.edu.cn,Port=8080+kbxx_classroom_ifr',
            data=classroom_data,
            headers=headers,
            verify=False)
        data_list = []
        soup = BeautifulSoup(response.text, 'html.parser')
        isVpnLoginSuccess = soup.find('span', class_='cssLarge')
        isAccountLoginSuccess = soup.find('div', class_='dlti')
        if not isVpnLoginSuccess:
            if not isAccountLoginSuccess:
                trs = soup.find_all("tr")
                for tr in trs[2:]:
                    tds = tr.find_all('td')
                    i = -1
                    for td in tds:
                        i = i + 1
                        data = {}
                        if '\r' in td.text:
                            data['place'] = tr.find_all('td')[0].text
                            data['time'] = trs[1].find_all('td')[i].text
                            if i >= 1 and i <= 5:
                                data['weekday'] = 'Mon'
                            elif i >= 6 and i <= 10:
                                data['weekday'] = 'Tue'
                            elif i >= 11 and i <= 15:
                                data['weekday'] = 'Wedn'
                            elif i >= 16 and i <= 20:
                                data['weekday'] = 'Thur'
                            elif i > 21 and i <= 25:
                                data['weekday'] = 'Fri'
                            elif i >= 26 and i <= 30:
                                data['weekday'] = 'Sat'
                            else:
                                data['weekday'] = 'Sun'
                            data_list.append(data)
                data_list = response_info.success("空教室查询成功", data_list)
            else:
                data_list = response_info.error(
                    static.JUST_ACCOUNT_LOGIN_ERROR, '教务系统账号或密码错误', '')
        else:
            data_list = response_info.error(static.JUST_VPN_LOGIN_ERROR,
                                            'vpn账号被占用', vpn_account)

    except Exception as e:
        logging.exception(e)
        r.rpush("vpn_account", vpn_account)
        raise
    finally:
        session.post('https://vpn.just.edu.cn/dana-na/auth/logout.cgi',
                     headers=headers,
                     verify=False)
    return data_list, vpn_account