mirror of
https://github.com/cqwu-ehall/cqwu-ehall.git
synced 2024-11-22 11:01:20 +00:00
parent
d2417fb906
commit
127fcf2df9
@ -15,6 +15,7 @@ class Client(Methods):
|
|||||||
password: str = None,
|
password: str = None,
|
||||||
cookie: str = None,
|
cookie: str = None,
|
||||||
cookie_file_path: str = "cookie.txt",
|
cookie_file_path: str = "cookie.txt",
|
||||||
|
timeout: int = 10,
|
||||||
):
|
):
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
@ -24,7 +25,7 @@ class Client(Methods):
|
|||||||
self.auth_host = "http://authserver.cqwu.edu.cn"
|
self.auth_host = "http://authserver.cqwu.edu.cn"
|
||||||
self.web_ehall_path = ""
|
self.web_ehall_path = ""
|
||||||
self.cookies = Cookies()
|
self.cookies = Cookies()
|
||||||
self.request = AsyncClient()
|
self.request = AsyncClient(timeout=timeout)
|
||||||
self.loop = asyncio.get_event_loop()
|
self.loop = asyncio.get_event_loop()
|
||||||
self.me: Optional[User] = None
|
self.me: Optional[User] = None
|
||||||
self._use_password_login = False
|
self._use_password_login = False
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
from .gen_pay_qrcode import GenPayQrcode
|
from .gen_pay_qrcode import GenPayQrcode
|
||||||
from .get_balance import GetBalance
|
from .get_balance import GetBalance
|
||||||
|
from .get_pay_bill import GetPayBill
|
||||||
|
|
||||||
|
|
||||||
class EPay(
|
class EPay(
|
||||||
GenPayQrcode,
|
GenPayQrcode,
|
||||||
GetBalance,
|
GetBalance,
|
||||||
|
GetPayBill,
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
27
cqwu/methods/epay/get_pay_bill.py
Normal file
27
cqwu/methods/epay/get_pay_bill.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import cqwu
|
||||||
|
from cqwu.errors.auth import CookieError
|
||||||
|
from cqwu.types.epay import PayBillPage
|
||||||
|
|
||||||
|
|
||||||
|
class GetPayBill:
|
||||||
|
async def get_pay_bill(
|
||||||
|
self: "cqwu.Client",
|
||||||
|
page_number: int = 1,
|
||||||
|
) -> PayBillPage:
|
||||||
|
"""
|
||||||
|
获取校园卡消费账单
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
PayBillPage: 消费账单
|
||||||
|
"""
|
||||||
|
url = "http://218.194.176.214:8382/epay/thirdapp/bill"
|
||||||
|
html = await self.oauth(url)
|
||||||
|
if not html:
|
||||||
|
raise CookieError()
|
||||||
|
if html.url != url:
|
||||||
|
raise CookieError()
|
||||||
|
data = await self.request.post(
|
||||||
|
"http://218.194.176.214:8382/epay/thirdapp/loadbill.json",
|
||||||
|
data={"pageno": page_number}
|
||||||
|
)
|
||||||
|
return PayBillPage(**data.json())
|
@ -1,7 +1,9 @@
|
|||||||
|
from .get_cp import GetCP
|
||||||
from .get_score import GetScore
|
from .get_score import GetScore
|
||||||
|
|
||||||
|
|
||||||
class XG(
|
class XG(
|
||||||
|
GetCP,
|
||||||
GetScore,
|
GetScore,
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
88
cqwu/methods/xg/get_cp.py
Normal file
88
cqwu/methods/xg/get_cp.py
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
import openpyxl
|
||||||
|
|
||||||
|
import cqwu
|
||||||
|
from cqwu.errors import CookieError
|
||||||
|
from cqwu.types.cp import CP
|
||||||
|
|
||||||
|
|
||||||
|
class GetCP:
|
||||||
|
async def get_cp(
|
||||||
|
self: "cqwu.Client",
|
||||||
|
year: int = None,
|
||||||
|
semester: int = None,
|
||||||
|
) -> CP:
|
||||||
|
""" 获取综合测评结果 """
|
||||||
|
xue_nian = year or self.xue_nian
|
||||||
|
xue_qi = semester or self.xue_qi
|
||||||
|
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)
|
||||||
|
url = "http://xg.cqwu.edu.cn/xsfw/sys/emapcomponent/imexport/export.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 = {
|
||||||
|
'app': 'zhcptybbapp',
|
||||||
|
'contextPath': 'http://xg.cqwu.edu.cn/xsfw',
|
||||||
|
'module': 'modules',
|
||||||
|
'page': 'cpjgcx',
|
||||||
|
'action': 'cpjgcxbgdz',
|
||||||
|
'containerId': 'cpjg_grid',
|
||||||
|
'CPXN': str(xue_nian),
|
||||||
|
'CPXQ': str(xue_qi),
|
||||||
|
'filename': '综合测评结果',
|
||||||
|
'colnames': 'XH,XM,CPXN,CPXQ,DWDM,DZ_ZYFX,BJDM,ZCJ,BJPM,BJRS,ZYNJPM,ZYNJRS,FS1,FS10,FS11,FS12,'
|
||||||
|
'XZNJ,DZ_BJPM,DZ_ZYPM',
|
||||||
|
}
|
||||||
|
html = await self.request.post(url, headers=headers, data=data)
|
||||||
|
if html.status_code != 200:
|
||||||
|
raise CookieError()
|
||||||
|
html_data = html.json()
|
||||||
|
url = f"http://xg.cqwu.edu.cn/xsfw/sys/emapcomponent/file/getAttachmentFile/{html_data['attachment']}.do"
|
||||||
|
xlsx_file = await self.request.get(url, headers=headers)
|
||||||
|
wb = openpyxl.load_workbook(filename=BytesIO(xlsx_file.content))
|
||||||
|
ws = wb.active
|
||||||
|
wz = ws[2]
|
||||||
|
return CP(
|
||||||
|
id=int(wz[0].value),
|
||||||
|
name=wz[1].value,
|
||||||
|
xue_nian=wz[2].value,
|
||||||
|
xue_qi=wz[3].value,
|
||||||
|
score=float(wz[7].value),
|
||||||
|
class_rank=int(wz[8].value),
|
||||||
|
class_member=int(wz[9].value),
|
||||||
|
grade_rank=int(wz[10].value),
|
||||||
|
grade_member=int(wz[11].value),
|
||||||
|
dysz=float(wz[12].value),
|
||||||
|
zysz=float(wz[13].value),
|
||||||
|
cxsz=float(wz[14].value),
|
||||||
|
wtsz=float(wz[15].value),
|
||||||
|
zysz_class_rank=int(wz[17].value),
|
||||||
|
zysz_grade_rank=int(wz[18].value),
|
||||||
|
)
|
19
cqwu/types/cp.py
Normal file
19
cqwu/types/cp.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class CP(BaseModel):
|
||||||
|
id: int
|
||||||
|
name: str
|
||||||
|
xue_nian: str
|
||||||
|
xue_qi: str
|
||||||
|
score: float
|
||||||
|
class_rank: int
|
||||||
|
class_member: int
|
||||||
|
grade_rank: int
|
||||||
|
grade_member: int
|
||||||
|
dysz: float
|
||||||
|
zysz: float
|
||||||
|
cxsz: float
|
||||||
|
wtsz: float
|
||||||
|
zysz_class_rank: int
|
||||||
|
zysz_grade_rank: int
|
20
cqwu/types/epay.py
Normal file
20
cqwu/types/epay.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from typing import List
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class PayBill(BaseModel):
|
||||||
|
id: str
|
||||||
|
amount: float
|
||||||
|
tradename: str
|
||||||
|
shopname: str
|
||||||
|
paytime: int
|
||||||
|
status: int
|
||||||
|
|
||||||
|
|
||||||
|
class PayBillPage(BaseModel):
|
||||||
|
pageno: int
|
||||||
|
totalpage: int
|
||||||
|
retcode: int
|
||||||
|
retmsg: str
|
||||||
|
dtls: List[PayBill]
|
@ -5,3 +5,4 @@ beautifulsoup4==4.11.2
|
|||||||
qrcode==7.4.2
|
qrcode==7.4.2
|
||||||
pillow
|
pillow
|
||||||
pydantic==1.10.5
|
pydantic==1.10.5
|
||||||
|
openpyxl
|
||||||
|
3
setup.py
3
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.8", # 包版本号,便于维护版本
|
version="0.0.9", # 包版本号,便于维护版本
|
||||||
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.", # 包的简述
|
||||||
@ -27,5 +27,6 @@ setuptools.setup(
|
|||||||
"qrcode",
|
"qrcode",
|
||||||
"pillow",
|
"pillow",
|
||||||
"pydantic",
|
"pydantic",
|
||||||
|
"openpyxl",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user