mirror of
https://github.com/cqwu-ehall/cqwu-ehall.git
synced 2024-11-22 02:55:33 +00:00
✨ Support ZPublic HCP
This commit is contained in:
parent
127fcf2df9
commit
979d575182
@ -1,9 +1,36 @@
|
|||||||
|
import cqwu
|
||||||
|
|
||||||
from .get_cp import GetCP
|
from .get_cp import GetCP
|
||||||
|
from .get_public_cp import GetPublicCP
|
||||||
from .get_score import GetScore
|
from .get_score import GetScore
|
||||||
|
from ...errors import CookieError
|
||||||
|
|
||||||
|
|
||||||
class XG(
|
class XG(
|
||||||
GetCP,
|
GetCP,
|
||||||
|
GetPublicCP,
|
||||||
GetScore,
|
GetScore,
|
||||||
):
|
):
|
||||||
pass
|
async def oauth_xg(
|
||||||
|
self: "cqwu.Client",
|
||||||
|
):
|
||||||
|
url = "http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/*default/index.do#/cjcx"
|
||||||
|
html = await self.oauth(url)
|
||||||
|
if not html:
|
||||||
|
raise CookieError()
|
||||||
|
if html.url != url:
|
||||||
|
raise CookieError()
|
||||||
|
url = "http://xg.cqwu.edu.cn/xsfw/sys/swpubapp/indexmenu/getAppConfig.do"
|
||||||
|
headers = {
|
||||||
|
'Accept': '*/*',
|
||||||
|
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,hu;q=0.5',
|
||||||
|
'Connection': 'keep-alive',
|
||||||
|
'Referer': 'http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/*default/index.do',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51',
|
||||||
|
}
|
||||||
|
params = {
|
||||||
|
'appId': '5275772372599202',
|
||||||
|
'appName': 'zhcptybbapp',
|
||||||
|
'v': '021534151969418724',
|
||||||
|
}
|
||||||
|
await self.request.get(url, headers=headers, params=params)
|
||||||
|
@ -16,26 +16,7 @@ class GetCP:
|
|||||||
""" 获取综合测评结果 """
|
""" 获取综合测评结果 """
|
||||||
xue_nian = year or self.xue_nian
|
xue_nian = year or self.xue_nian
|
||||||
xue_qi = semester or self.xue_qi
|
xue_qi = semester or self.xue_qi
|
||||||
url = "http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/*default/index.do#/cjcx"
|
await self.oauth_xg()
|
||||||
html = await self.oauth(url)
|
|
||||||
if not html:
|
|
||||||
raise CookieError()
|
|
||||||
if html.url != url:
|
|
||||||
raise CookieError()
|
|
||||||
url = "http://xg.cqwu.edu.cn/xsfw/sys/swpubapp/indexmenu/getAppConfig.do"
|
|
||||||
headers = {
|
|
||||||
'Accept': '*/*',
|
|
||||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,hu;q=0.5',
|
|
||||||
'Connection': 'keep-alive',
|
|
||||||
'Referer': 'http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/*default/index.do',
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51',
|
|
||||||
}
|
|
||||||
params = {
|
|
||||||
'appId': '5275772372599202',
|
|
||||||
'appName': 'zhcptybbapp',
|
|
||||||
'v': '021534151969418724',
|
|
||||||
}
|
|
||||||
await self.request.get(url, headers=headers, params=params)
|
|
||||||
url = "http://xg.cqwu.edu.cn/xsfw/sys/emapcomponent/imexport/export.do"
|
url = "http://xg.cqwu.edu.cn/xsfw/sys/emapcomponent/imexport/export.do"
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||||
|
70
cqwu/methods/xg/get_public_cp.py
Normal file
70
cqwu/methods/xg/get_public_cp.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
from typing import List
|
||||||
|
|
||||||
|
import cqwu
|
||||||
|
from cqwu.errors import CookieError
|
||||||
|
from cqwu.types.cp import CPGS, PublicCPRaw
|
||||||
|
|
||||||
|
|
||||||
|
class GetPublicCP:
|
||||||
|
async def get_public_cp(
|
||||||
|
self: "cqwu.Client",
|
||||||
|
page_size: int = 999,
|
||||||
|
page_number: int = 1,
|
||||||
|
total: bool = True,
|
||||||
|
) -> List[PublicCPRaw]:
|
||||||
|
""" 获取综合测评公示结果 """
|
||||||
|
await self.oauth_xg()
|
||||||
|
|
||||||
|
async def get_public_cp_raw(page_size_: int, page_number_: int) -> CPGS:
|
||||||
|
url = "http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/modules/cpgs/cpgs_cpgsbg.do"
|
||||||
|
headers = {
|
||||||
|
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||||
|
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,hu;q=0.5',
|
||||||
|
'Connection': 'keep-alive',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||||
|
'Origin': 'http://xg.cqwu.edu.cn',
|
||||||
|
'Referer': 'http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/*default/index.do',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51',
|
||||||
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
'querySetting': '[]',
|
||||||
|
'pageSize': str(page_size_),
|
||||||
|
'pageNumber': str(page_number_),
|
||||||
|
}
|
||||||
|
html = await self.request.post(url, headers=headers, data=data)
|
||||||
|
if html.status_code != 200:
|
||||||
|
raise CookieError()
|
||||||
|
html_data = html.json()
|
||||||
|
html_raw_data = html_data.get("datas", {}).get("cpgs_cpgsbg", {})
|
||||||
|
return (
|
||||||
|
CPGS(**html_raw_data)
|
||||||
|
if html_raw_data
|
||||||
|
else CPGS(
|
||||||
|
totalSize=0,
|
||||||
|
pageNumber=page_number_,
|
||||||
|
pageSize=page_size_,
|
||||||
|
rows=[],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return_datas: List[PublicCPRaw] = []
|
||||||
|
if total:
|
||||||
|
page_size = 999
|
||||||
|
page_number = 1
|
||||||
|
while True:
|
||||||
|
html_raw_datas = await get_public_cp_raw(page_size, page_number)
|
||||||
|
if len(html_raw_datas.rows) == 0:
|
||||||
|
break
|
||||||
|
return_datas.extend(html_raw_datas.rows)
|
||||||
|
if html_raw_datas.totalSize == 0:
|
||||||
|
break
|
||||||
|
elif html_raw_datas.pageNumber * html_raw_datas.pageSize >= html_raw_datas.totalSize:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
page_number += 1
|
||||||
|
else:
|
||||||
|
html_raw_datas = await get_public_cp_raw(page_size, page_number)
|
||||||
|
if len(html_raw_datas.rows) != 0:
|
||||||
|
return_datas.extend(html_raw_datas.rows)
|
||||||
|
return return_datas
|
@ -1,9 +1,7 @@
|
|||||||
import json
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import cqwu
|
import cqwu
|
||||||
from cqwu import types
|
from cqwu import types
|
||||||
from cqwu.errors.auth import CookieError
|
|
||||||
|
|
||||||
|
|
||||||
class GetScore:
|
class GetScore:
|
||||||
@ -20,14 +18,7 @@ class GetScore:
|
|||||||
"""
|
"""
|
||||||
year = year or self.xue_nian
|
year = year or self.xue_nian
|
||||||
semester = semester or self.xue_qi
|
semester = semester or self.xue_qi
|
||||||
url = "http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/*default/index.do#/cjcx"
|
await self.oauth_xg()
|
||||||
html = await self.oauth(url)
|
|
||||||
if not html:
|
|
||||||
raise CookieError()
|
|
||||||
if html.url != url:
|
|
||||||
raise CookieError()
|
|
||||||
await self.request.get(
|
|
||||||
"http://xg.cqwu.edu.cn/xsfw/sys/swpubapp/indexmenu/getAppConfig.do?appId=5275772372599202&appName=zhcptybbapp&v=046351851777942055")
|
|
||||||
query_url = "http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/modules/cjcx/cjcxbgdz.do"
|
query_url = "http://xg.cqwu.edu.cn/xsfw/sys/zhcptybbapp/modules/cjcx/cjcxbgdz.do"
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||||
|
102
cqwu/types/cp.py
102
cqwu/types/cp.py
@ -1,3 +1,5 @@
|
|||||||
|
from typing import List
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
@ -17,3 +19,103 @@ class CP(BaseModel):
|
|||||||
wtsz: float
|
wtsz: float
|
||||||
zysz_class_rank: int
|
zysz_class_rank: int
|
||||||
zysz_grade_rank: int
|
zysz_grade_rank: int
|
||||||
|
|
||||||
|
|
||||||
|
class PublicCPRaw(BaseModel):
|
||||||
|
XH: str
|
||||||
|
XM: str
|
||||||
|
DWDM_DISPLAY: str
|
||||||
|
ZYDM_DISPLAY: str
|
||||||
|
BJDM_DISPLAY: str
|
||||||
|
ZCJ: float
|
||||||
|
BJPM: int
|
||||||
|
ZYNJPM: int
|
||||||
|
FS1: float
|
||||||
|
FS10: float
|
||||||
|
FS11: float
|
||||||
|
FS12: float
|
||||||
|
DYYSCJ: str
|
||||||
|
WTYSCJ: str
|
||||||
|
CXYSCJ: str
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
""" 学号 """
|
||||||
|
return int(self.XH)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
""" 姓名 """
|
||||||
|
return self.XM
|
||||||
|
|
||||||
|
@property
|
||||||
|
def yuan_xi(self) -> str:
|
||||||
|
""" 院系 """
|
||||||
|
return self.DWDM_DISPLAY
|
||||||
|
|
||||||
|
@property
|
||||||
|
def zhuan_ye(self) -> str:
|
||||||
|
""" 专业 """
|
||||||
|
return self.ZYDM_DISPLAY
|
||||||
|
|
||||||
|
@property
|
||||||
|
def class_name(self) -> str:
|
||||||
|
""" 班级 """
|
||||||
|
return self.BJDM_DISPLAY
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total_score(self) -> float:
|
||||||
|
""" 总成绩 """
|
||||||
|
return float(self.ZCJ)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def class_rank(self) -> int:
|
||||||
|
""" 班级排名 """
|
||||||
|
return int(self.BJPM)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def grade_rank(self) -> int:
|
||||||
|
""" 专业年级排名 """
|
||||||
|
return int(self.ZYNJPM)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dysz(self) -> float:
|
||||||
|
""" 德育素质分 """
|
||||||
|
return float(self.FS1)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def zysz(self) -> float:
|
||||||
|
""" 智育素质测评 """
|
||||||
|
return float(self.FS10)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cxsz(self) -> float:
|
||||||
|
""" 创新素质测评 """
|
||||||
|
return float(self.FS11)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def wtsz(self) -> float:
|
||||||
|
""" 文体素质 """
|
||||||
|
return float(self.FS12)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dysz_raw(self) -> float:
|
||||||
|
""" 德育原始成绩 """
|
||||||
|
return float(self.DYYSCJ)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def wtsz_raw(self) -> float:
|
||||||
|
""" 文体原始成绩 """
|
||||||
|
return float(self.WTYSCJ)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cxsz_raw(self) -> float:
|
||||||
|
""" 创新原始成绩 """
|
||||||
|
return float(self.CXYSCJ)
|
||||||
|
|
||||||
|
|
||||||
|
class CPGS(BaseModel):
|
||||||
|
totalSize: int
|
||||||
|
pageNumber: int
|
||||||
|
pageSize: int
|
||||||
|
rows: List[PublicCPRaw]
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="cqwu", # 用自己的名替换其中的YOUR_USERNAME_
|
name="cqwu", # 用自己的名替换其中的YOUR_USERNAME_
|
||||||
version="0.0.9", # 包版本号,便于维护版本
|
version="0.0.10", # 包版本号,便于维护版本
|
||||||
author="omg-xtao", # 作者,可以写自己的姓名
|
author="omg-xtao", # 作者,可以写自己的姓名
|
||||||
author_email="xtao@xtaolink.cn", # 作者联系方式,可写自己的邮箱地址
|
author_email="xtao@xtaolink.cn", # 作者联系方式,可写自己的邮箱地址
|
||||||
description="A cqwu ehall client.", # 包的简述
|
description="A cqwu ehall client.", # 包的简述
|
||||||
|
Loading…
Reference in New Issue
Block a user