Last active
August 29, 2015 14:04
-
-
Save lanfon72/b2e1cb6fc4b2fb2d2957 to your computer and use it in GitHub Desktop.
parse ndmctsgh live ER status boaard
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 | |
os.environ['TZ'] = 'ROC' | |
html = requests.get('http://www1.ndmctsgh.edu.tw/ErOnlineNews/ErOnLineData.aspx') | |
pending = re.findall(u'd">(.+)</fon',html.text) | |
# prase like ['否', '3', '0', '9', '0'] | |
values = [ int(ele) for ele in pending[1:] ] | |
keys = ['pending_doctor','pending_bed', 'pending_ward', 'pending_icu'] | |
report = { key:value for value, key in zip(values, keys) } | |
report["hospital_sn"] = '0501110514' | |
report['full_reported'] = False if u'否' in pending[0] else True | |
report["update_time"] = 'null' | |
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