Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能保证打卡地点一定是上海吗 #40

Open
lees2019 opened this issue Sep 25, 2022 · 1 comment
Open

能保证打卡地点一定是上海吗 #40

lees2019 opened this issue Sep 25, 2022 · 1 comment

Comments

@lees2019
Copy link

因为国庆要出校,所以定位得是上海,这个获取地址是通过什么,确定为上海的?请指教下

@YangMindiDeMajia
Copy link

last_info = ''

def check(self):
    """
    检查
    """
    print("◉检测是否已提交")
    get_info = self.session.get(
        'https://zlapp.fudan.edu.cn/ncov/wap/fudan/get-info')
    last_info = get_info.json()

    print("◉上一次提交日期为:", last_info["d"]["info"]["date"])
    # 地区从oldInfo中提取
    last_area = last_info["d"]["oldInfo"]["area"]
    print("◉上一次提交的地区是:", last_area)
    if last_area == "其他国家":
        pass
    else:
        position = last_info["d"]["info"]['geo_api_info']
        position = json_loads(position)

        print("◉上一次提交地址为:", position['formattedAddress'])
        # print("◉上一次提交GPS为", position["position"])
    # print(last_info)
    
    # 改为上海时区
    os.environ['TZ'] = 'Asia/Shanghai'
    time.tzset()
    today = time.strftime("%Y%m%d", time.localtime())
    print("◉今日日期为:", today)
    if last_info["d"]["info"]["date"] == today:
        print("\n*******今日已提交*******")
        self.close()
    else:
        print("\n\n*******未提交*******")
        self.last_info = last_info["d"]["oldInfo"]

def checkin(self):
"""
提交
"""
headers = {
"Host": "zlapp.fudan.edu.cn",
"Referer": "https://zlapp.fudan.edu.cn/site/ncov/fudanDaily?from=history",
"DNT": "1",
"TE": "Trailers",
"User-Agent": self.UA
}

    print("\n\n◉◉提交中")
    
    province = self.last_info["province"]
    city = self.last_info["city"]
    area = self.last_info["area"]
    if area == "其他国家":
        gwszdd = self.last_info["gwszdd"]
    else:
        geo_api_info = json_loads(self.last_info["geo_api_info"])
        district = geo_api_info["addressComponent"].get("district", "")
    
    while(True):
        print("◉正在识别验证码......")
        code = self.validate_code()
        print("◉验证码为:", code)
        if area == "其他国家":
            self.last_info.update(
                {
                    "tw": "13",
                    "province": province,
                    "city": city,
                    "area": area,
                    "gwszdd": gwszdd,
                    #"sfzx": "1",  # 是否在校
                    #"fxyy": "",  # 返校原因
                    "code": code,
                }
            )
        else:
            self.last_info.update(
                {
                    "tw": "13",
                    "province": province,
                    "city": city,
                    "area": " ".join((province, city, district)),
                    #"sfzx": "1",  # 是否在校
                    #"fxyy": "",  # 返校原因
                    "code": code,
                }
            )
        # print(self.last_info)
        save = self.session.post(
            'https://zlapp.fudan.edu.cn/ncov/wap/fudan/save',
            data=self.last_info,
            headers=headers,
            allow_redirects=False)

        save_msg = json_loads(save.text)["m"]
        print(save_msg, '\n\n')
        time.sleep(0.1)
        if(json_loads(save.text)["e"] != 1):
            break

由这两大块代码综合可见,这个获取地址是获取的你上一次打卡的地址。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants