Created
December 3, 2016 08:16
-
-
Save lancetw/6a1e3ba23302bad6e576135861afe5a4 to your computer and use it in GitHub Desktop.
Cathay general hospital Hsinchu branch ER board. (updated 20161203)
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
# !/usr/bin/env python | |
# coding:UTF-8 | |
import requests, json, re | |
from datetime import datetime | |
html = requests.get('http://med.cgh.org.tw/unit/branch/Pharmacy/ebl/RealTimeInfoHC.html', verify=False) | |
keys = ['pending_doctor', 'pending_bed', 'pending_ward', 'pending_icu'] | |
pending0 = re.findall(r"<td(.*?)>(.+?)</td>", html.text) | |
pending1 = re.findall(r"<p(.*?)>(.+?)</p>", html.text) | |
values = [int(ele[1]) for ele in pending0[2::4][1:]] | |
report = {k: v for k, v in zip(keys, values)} | |
report['hospital_sn'] = "1112010528" | |
report['full_reported'] = True if u"是" in (pending0[2::4][0:][0][1]).encode('latin1', 'ignore').decode('big5') else False | |
upt = ':'.join(pending1[-1][1].encode('latin1', 'ignore').decode('big5').split(u":")[1:]) | |
upt = upt.replace(upt[0:3], str(int(upt[0:3])+ 1911)) | |
report['update_time'] = datetime.strptime(upt, '%Y/%m/%d %H:%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