Last active
March 2, 2017 13:14
-
-
Save lanfon72/15f07be43dfadd14ed8d6ac732e7c8e9 to your computer and use it in GitHub Desktop.
Kaohsiung Veterans General Hospital ER.
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 re | |
| import os | |
| import json | |
| from datetime import datetime | |
| import requests | |
| os.environ['TZ'] = 'ROC' | |
| html = requests.get(r"http://www.vghks.gov.tw/Json_Read.aspx?type=1&url=http://wwwmgr.vghks.gov.tw/Upload/vghksbed/List_Emergency.json") | |
| keys = ['pending_doctor', 'pending_bed', 'pending_ward', 'pending_icu'] | |
| pending = re.findall(r'Td2">(.+)</d', html.text, re.UNICODE) | |
| values = [int(ele.replace(u"人", '').strip()) for ele in pending[1:]] | |
| report = {k: v for k, v in zip(keys, values)} | |
| report['hospital_sn'] = "0602030026" | |
| report['full_reported'] = False if u"否" in pending[0] else True | |
| upt = re.findall(u"時間:</span>(.+)\r", html.text)[0] | |
| report["update_time"] = datetime.strptime(upt, u"%Y-%m-%d %H:%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