Created
February 25, 2015 06:57
-
-
Save lanfon72/3a3221b3867121114e92 to your computer and use it in GitHub Desktop.
parse Chimei Liuying 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)[21:28] | |
| 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"] = '1141090512' | |
| 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