Skip to content

Instantly share code, notes, and snippets.

@lanfon72
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save lanfon72/14f08fc32ad0552e7059 to your computer and use it in GitHub Desktop.

Select an option

Save lanfon72/14f08fc32ad0552e7059 to your computer and use it in GitHub Desktop.
parse ChiMei Hospital live ER status.
#!/usr/bin/env python
#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)[7:14]
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"] = '1141310019'
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