Created
March 3, 2017 14:39
-
-
Save lanfon72/377feb93f92db059f9347acceff12e19 to your computer and use it in GitHub Desktop.
parse cmuh live ER status board.
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.post(r"http://61.66.117.28/EmrCount/Default.aspx") | |
| pending = re.findall(r'"Black".+>(.+)</font>', html.text, re.UNICODE) | |
| values = [int(ele) for ele in pending[2:]] | |
| keys = ['pending_doctor', 'pending_bed', 'pending_ward', 'pending_icu'] | |
| report = {key: value for value, key in zip(values, keys)} | |
| upt = re.search(r'1">(.+)</s', html.text).group(1) | |
| update_time = upt.replace(u'上午', 'am') if u'上午' in upt else upt.replace(u'下午', 'pm') | |
| report["hospital_sn"] = '1131100010' | |
| report['full_reported'] = False if u'否' in pending[1] else True | |
| report["update_time"] = datetime.strptime(update_time, '%Y/%m/%d %p %I:%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