Created
March 22, 2023 03:15
-
-
Save qnnnnez/49d3e35293de6fd1adf8f05f80752da3 to your computer and use it in GitHub Desktop.
深圳出入境预约查询
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locations = ['440305000000', '440305000001'] | |
start_date = '2023-03-03' | |
query_days = 7 | |
url = "https://msjw.ga.sz.gov.cn/crj/crjmsjw/wsyydata/getScheduleData" | |
import requests | |
import os | |
import time | |
def do_req(location): | |
payload = { | |
'yywdbh': location, | |
'blyw': '-1', | |
'startDate': start_date, | |
'type': '1', | |
'days': query_days, | |
'lang': 'CH', | |
'ywlx': 'szjm', | |
} | |
resp = requests.request("POST", url, data=payload) | |
resp.raise_for_status() | |
data = resp.json() | |
assert data['success'] == 1 | |
return data['data']['dataList'] | |
def notify(title, text): | |
os.system(""" | |
osascript -e 'display notification "{}" with title "{}"' | |
""".format(text, title)) | |
def main(): | |
while True: | |
for location in locations: | |
for d in do_req(location): | |
if d['date'] in ('2023-03-03', '2023-03-04', '2023-03-05') and d['context'].startswith('可预约'): | |
if d['date'] == '2023-03-03' and location == '440305000000': | |
if d['time'] not in ['18:00-19:00', '19:00-20:00']: | |
continue | |
print(f'{location} {d["date"]} {d["time"]}') | |
print('https://msjw.ga.sz.gov.cn/crj/crjmsjw/wsyy/ajax/scheduleSzjm.html') | |
notify('hk', 'found') | |
return | |
print('.', end='') | |
time.sleep(30) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment