-
-
Save lancetw/0600b55d12a130667468f872b408bd4c to your computer and use it in GitHub Desktop.
NTU hospital hsin-chu branch ER board.
This file contains hidden or 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
# !/usr/bin/env python | |
# coding:UTF-8 | |
import requests, json, re | |
from datetime import datetime | |
html = requests.get('http://reg.ntuh.gov.tw/EmgInfoBoard/NTUHEmgInfoT4.aspx', verify=False) | |
keys = ['pending_doctor', 'pending_ward', 'pending_icu', 'pending_bed'] | |
pending0 = re.findall(r"<td(.*?)>(.+?)</td>", html.text) | |
pending1 = re.findall(r"<div(.*?)>(.+?)</div>", html.text) | |
values = [int(ele[1].replace(u"人", '')) for ele in pending0[1::2][1:]] | |
report = {k: v for k, v in zip(keys, values)} | |
report['hospital_sn'] = "0412040012" | |
report['full_reported'] = False if u"未通報" in pending1[1][1] else True | |
upt = pending0[-1][1].split(u":")[-1] | |
upt = upt.replace(u" 上午 ", 'am') if u"上午" in upt else upt.replace(u" 下午 ", 'pm') | |
report['update_time'] = datetime.strptime(upt, '%Y/%m/%d%p%I:%M:%S').strftime("%s") | |
print(json.dumps(report, ensure_ascii=False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment