Last active
August 29, 2015 14:04
-
-
Save lanfon72/b43d515d69041a1dae14 to your computer and use it in GitHub Desktop.
parse vghtpe live ER status board
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, re, json, os | |
from datetime import datetime | |
os.environ['TZ'] = 'ROC' | |
html = requests.get('http://www6.vghtpe.gov.tw/ERREALIFO/ERREALIFO.jsp') | |
html.encoding='big5' | |
pending = re.findall(u'">?(\w+)</font>',html.text) | |
full_reported = re.findall(u'體">?(.?)</font>',html.text)[0] | |
# prase like ['2', '0', '20', '0'] | |
keys = ['pending_doctor','pending_bed', 'pending_ward', 'pending_icu'] | |
report = { key:value for value, key in zip(pending, keys) } | |
report["hospital_sn"] = '0601160016' | |
report['full_reported'] = False if full_reported==u'否' else True | |
report["update_time"] = 'null' | |
print ( json.dumps(report, ensure_ascii=False) ) | |
# [{"update_time": "1407226207", "full_reported": true, "pending_bed": 16, "Hosptial_SN": "0601160016", "pending_doctor": 0, "pending_ward": 0}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment