Skip to content

Instantly share code, notes, and snippets.

@lancetw
Last active December 19, 2018 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lancetw/5fa76390f10469d86e2c28c1dd964512 to your computer and use it in GitHub Desktop.
Save lancetw/5fa76390f10469d86e2c28c1dd964512 to your computer and use it in GitHub Desktop.
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