Skip to content

Instantly share code, notes, and snippets.

@lancetw
Last active Dec 19, 2018
Embed
What would you like to do?
Mackay memorial hospital Hsinchu branch ER board. (updated 20181219)
# !/usr/bin/env python
# coding:UTF-8
import requests, json, re
from datetime import datetime
requests.packages.urllib3.disable_warnings()
html = requests.get('https://wapps.mmh.org.tw/WebEMR/WebEMR/Default.aspx?a=HC', verify=False)
keys = ['pending_doctor', 'pending_bed', 'pending_ward', 'pending_icu']
pending = re.findall(r"<td(.*?)><font(.*?)>(.+?)</font></td>", html.text)
values = [int(ele[2]) for ele in pending[1::2][2:6]]
report = {k: v for k, v in zip(keys, values)}
report['hospital_sn'] = "1112010519"
report['full_reported'] = True if u"是" in pending[1::2][1:][0][2] else False
upt = pending[1][2]
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').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