NLDNLD

复制代码
import requests
import time

# authorization = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsic2VjdXJpdHktc2VydmVyIl0sInVzZXJfbmFtZSI6IjE1ODE4NDI1MDUxIiwic2NvcGUiOlsiYWxsIl0sImV4cCI6MTY5Njg0NTkxNiwidXNlcklkIjoxOTA0MDIsImp0aSI6Ijc1NzExMzA2LTgzYzctNDNhOC1iODYwLWM4ZWNjOGM4MTI5MyIsImNsaWVudF9pZCI6InNlY3VyaXR5LWFwcCIsInVzZXJuYW1lIjoiMTU4MTg0MjUwNTEifQ.1H2SbRZ-KPDjqYAqStQ42tsXkv_aK1AZEuAzc6qkCdM'
authorization = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsic2VjdXJpdHktc2VydmVyIl0sInVzZXJfbmFtZSI6IjE1ODE4NDI1MDUxIiwic2NvcGUiOlsiYWxsIl0sImV4cCI6MTY5Njg0ODI4MywidXNlcklkIjoxOTA0MDIsImp0aSI6IjU4NzgzZDgwLTJiMmQtNGNhNy1iMjgzLTAzMzE0MDk1OGRhMCIsImNsaWVudF9pZCI6InNlY3VyaXR5LWFwcCIsInVzZXJuYW1lIjoiMTU4MTg0MjUwNTEifQ.-kPe8ubqHj3ja1HjsH03vAsq67hM_3vQXaju5BWqlpw'
headers = {
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Content-Type': 'application/json,application/json',
    'Referer': 'https://servicewechat.com/wx5f1853171795aa44/53/page-frame.html',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'cross-site',
    'xweb_xhr': '1',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF XWEB/8447',
}
import datetime


def booking(bookingTimeId, visitStartTime, visitEndTime):
    headers = {
        'Content-Type': 'application/json',
        'Accept-Language': 'zh-CN,zh;q=0.9',
        'authorization': authorization,
        'Connection': 'keep-alive',
        'Referer': 'https://servicewechat.com/wx5f1853171795aa44/53/page-frame.html',
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
        'xweb_xhr': '1',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF XWEB/8447',
    }

    data = {
        "visitType": 0, "visitWay": 0, "swiperIndex": 0, "reserveId": "126",
        "bookingVisitList": [
            {"age": 33, "ageStructureType": 1, "cellphone": AAA, "fullName": "AAA",
             "idNumber": "AAA", "idType": 0, "sex": 0, "ethnicity": "汉", "nationality": "中国",
             "nativePlace": "汕头", "currentPhysicalCondition": "良好"},
            {"age": 6, "ageStructureType": 0, "cellphone": AAA, "fullName": "AAA",
             "idNumber": "AAA",
             "idType": 0, "sex": 0, "ethnicity": "汉", "nationality": "中国", "nativePlace": "汕头",
             "currentPhysicalCondition": "良好"}
        ], "emergencyContact": "", "emergencyContactEmail": "",
        "emergencyContactPhone": "", "visitStartTime": visitStartTime, "visitEndTime": visitEndTime,
        "visitNature": None, "saveTeamInfo": None, "leader": None, "leaderIdType": 0, "leaderIdcard": None,
        "leaderPhone": None, "leaderEthnicity": None, "leaderNationality": None, "leaderNativePlace": None,
        "leaderCurrentPhysicalCondition": None, "unitCrrtificateImg": None, "visitorListImg": None,
        "teamListImg": [], "epidemicPrevention": [], "reportType": None, "reportSubmitDate": None, "leaderAge": 33,
        "expertPhotoUrl": None, "visitCount": 2, "teamName": None, "visitPurpose": None,
        "bookingTimeId": bookingTimeId, "activityId": None}
    print(data)

    response = requests.post('https://zhpt.lyj.gd.gov.cn/fimp/booking/wechat/booking', headers=headers, json=data,
                             verify=False)
    print(response.json())


while True:
    now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    response = requests.get('https://zhpt.lyj.gd.gov.cn/fimp/booking/wechat/home/reserve/126', headers=headers,
                            verify=False
                            )
    r = response.json()
    num = 0
    days = r["data"]["days"]
    print(f"{r['data']['lastModifyTime']} -- {days[0]['bookingDate']} -- {days[-1]['bookingDate']}")
    for day in days:
        if day['surplus'] > 1:
            num += 1

            for time in day["times"]:
                print(
                    f" {time['bookingStatisticID']}  -- {now} -- {day['bookingDate']} -- {time['bookingTime']} -- {time['surplus']} -- ")
                # if day["dayOfWeek"] in (6, 0):
                stime, etime = time['bookingTime'].split("~")
                booking(
                    time["bookingStatisticID"],
                    f"{day['bookingDate'][:10]} {stime}:00",
                    f"{day['bookingDate'][:10]} {etime}:00"
                )
                raise Exception("stop")
    else:
        if not num:
            print(f"{now} -- :木有票")
        else:
            break
    time.sleep(3)
相关推荐
狐凄20 分钟前
Python实例题:基于 Python 的简单聊天机器人
开发语言·python
悦悦子a啊1 小时前
Python之--基本知识
开发语言·前端·python
笑稀了的野生俊3 小时前
在服务器中下载 HuggingFace 模型:终极指南
linux·服务器·python·bash·gpu算力
Naiva3 小时前
【小技巧】Python+PyCharm IDE 配置解释器出错,环境配置不完整或不兼容。(小智AI、MCP、聚合数据、实时新闻查询、NBA赛事查询)
ide·python·pycharm
路来了4 小时前
Python小工具之PDF合并
开发语言·windows·python
蓝婷儿4 小时前
Python 机器学习核心入门与实战进阶 Day 3 - 决策树 & 随机森林模型实战
人工智能·python·机器学习
AntBlack4 小时前
拖了五个月 ,不当韭菜体验版算是正式发布了
前端·后端·python
.30-06Springfield4 小时前
决策树(Decision tree)算法详解(ID3、C4.5、CART)
人工智能·python·算法·决策树·机器学习
我不是哆啦A梦4 小时前
破解风电运维“百模大战”困局,机械版ChatGPT诞生?
运维·人工智能·python·算法·chatgpt
WJ.Polar5 小时前
Python数据容器-list和tuple
开发语言·python