diff --git a/cqwu/methods/webvpn/__init__.py b/cqwu/methods/webvpn/__init__.py
index 154eb46..a62a236 100644
--- a/cqwu/methods/webvpn/__init__.py
+++ b/cqwu/methods/webvpn/__init__.py
@@ -3,6 +3,7 @@ from httpx import URL
from .get_calendar import GetCalendar
from .get_calendar_change import GetCalendarChange
from .get_exam_calendar import GetExamCalendar
+from .get_selected_courses import GetSelectedCourses
from .login_jwmis import LoginJwmis
from .login_webvpn import LoginWebVPN
@@ -11,6 +12,7 @@ class WebVPN(
GetCalendar,
GetCalendarChange,
GetExamCalendar,
+ GetSelectedCourses,
LoginJwmis,
LoginWebVPN,
):
diff --git a/cqwu/methods/webvpn/get_selected_courses.py b/cqwu/methods/webvpn/get_selected_courses.py
new file mode 100644
index 0000000..79ade16
--- /dev/null
+++ b/cqwu/methods/webvpn/get_selected_courses.py
@@ -0,0 +1,90 @@
+import re
+from typing import Tuple, List, Union
+
+from bs4 import BeautifulSoup
+
+import cqwu
+from cqwu.types.calendar import AiCourse
+
+
+class GetSelectedCourses:
+ async def get_selected_courses(
+ self: "cqwu.Client",
+ use_model: bool = False,
+ ) -> Union[str, List[AiCourse]]:
+ """ 获取选课结果 """
+ jw_html = await self.login_jwmis()
+ jw_host = self.get_web_vpn_host(jw_html.url)
+ jw_url = f"{jw_host}/cqwljw/student/wsxk.zxjg.jsp"
+ headers = {
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
+ 'Accept-Language': 'zh-CN,zh;q=0.9',
+ 'Connection': 'keep-alive',
+ 'Referer': f'{jw_host}/cqwljw/frame/homes.html',
+ 'Sec-Fetch-Dest': 'iframe',
+ 'Sec-Fetch-Mode': 'navigate',
+ 'Sec-Fetch-Site': 'same-origin',
+ 'Sec-Fetch-User': '?1',
+ 'Upgrade-Insecure-Requests': '1',
+ '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.41',
+ 'sec-ch-ua': '"Microsoft Edge";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
+ 'sec-ch-ua-mobile': '?0',
+ 'sec-ch-ua-platform': '"Windows"',
+ }
+ jw_html = await self.request.get(jw_url, headers=headers, timeout=60, follow_redirects=True)
+ jw_html = jw_html.text.replace("""""", "")
+ return (
+ parse_courses(jw_html)
+ if use_model
+ else jw_html.replace("
", '')
+ )
+
+
+def format_text(text: str) -> str:
+ return text.replace("\n", "").replace("\t", "").replace("\r", "").strip()
+
+
+def parse_courses(jw_html: str) -> List[AiCourse]:
+ courses = []
+ courses_keys = []
+ soup = BeautifulSoup(jw_html, "lxml")
+ trs = soup.find_all("tbody")[2].find_all("tr")
+ for tr in trs:
+ tds = tr.find_all("td")
+ name = format_text(tds[1].get_text()).split("]")[1]
+ teacher = format_text(tds[4].get_text())
+ calendars = str(tds[12]).replace("\u2002", "").split("
")
+ for calendar in calendars:
+ text = (BeautifulSoup(calendar, "lxml")).text.strip()
+ try:
+ position, weeks, day, start_num, sections = parse_weeks_and_sections(text)
+ except Exception:
+ continue
+ item = AiCourse(
+ name=name,
+ teacher=teacher,
+ position=position,
+ weeks=weeks,
+ day=day,
+ start_num=start_num,
+ sections=sections,
+ )
+ if item.key not in courses_keys:
+ courses_keys.append(item.key)
+ courses.append(item)
+ return courses
+
+
+def parse_weeks_and_sections(text: str) -> Tuple[str, List[int], int, int, int]:
+ # text: [1-3,5-17]周二[3-4节]格致-C305
+ position, weeks_list, day, start_num, sections = "", [], 0, 0, 0
+ weeks, days = text.split("周")
+ position = days.split("]")[1]
+ for week in re.findall(r"\d+-\d+", weeks):
+ for i in range(int(week.split("-")[0]), int(week.split("-")[1]) + 1):
+ weeks_list.append(i)
+ day = "一二三四五六日".index(days[0]) + 1
+ starts = re.findall(r"\d+-\d+", days)
+ start_num = int(starts[0].split("-")[0])
+ sections = int(starts[0].split("-")[1]) - start_num + 1
+ return position, weeks_list, day, start_num, sections
diff --git a/cqwu/types/epay.py b/cqwu/types/epay.py
index 8e1dd0b..11900e2 100644
--- a/cqwu/types/epay.py
+++ b/cqwu/types/epay.py
@@ -1,3 +1,4 @@
+from datetime import datetime
from typing import List
from pydantic import BaseModel
@@ -8,7 +9,7 @@ class PayBill(BaseModel):
amount: float
tradename: str
shopname: str
- paytime: int
+ paytime: datetime
status: int
diff --git a/setup.py b/setup.py
index 078c75f..49e1e77 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup(
name="cqwu", # 用自己的名替换其中的YOUR_USERNAME_
- version="0.0.14", # 包版本号,便于维护版本
+ version="0.0.15", # 包版本号,便于维护版本
author="omg-xtao", # 作者,可以写自己的姓名
author_email="xtao@xtaolink.cn", # 作者联系方式,可写自己的邮箱地址
description="A cqwu ehall client.", # 包的简述