Created
February 25, 2015 06:59
-
-
Save lanfon72/f174221a2d6b06479c61 to your computer and use it in GitHub Desktop.
parse Chimei Jiali Hospital 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 ptyhon | |
| #coding:UTF-8 | |
| import requests, json, re | |
| html = requests.get('http://www.chimei.org.tw/%E6%80%A5%E8%A8%BA%E5%8D%B3%E6%99%82%E8%A8%8A%E6%81%AF/main.aspx') | |
| pending = re.findall('">(.+?)</font>',html.text)[35:] | |
| pending[2:4] = [] | |
| values = [ int(ele) for ele in pending[1:] ] | |
| keys = ['pending_doctor', 'pending_ward', 'pending_icu', 'pending_bed'] | |
| report = { key:value for value, key in zip(values, keys) } | |
| report["hospital_sn"] = '1105050012' | |
| 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