Skip to content

Instantly share code, notes, and snippets.

@lanfon72
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanfon72/b2e1cb6fc4b2fb2d2957 to your computer and use it in GitHub Desktop.
Save lanfon72/b2e1cb6fc4b2fb2d2957 to your computer and use it in GitHub Desktop.
parse ndmctsgh live ER status boaard
#!/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