Skip to content

Instantly share code, notes, and snippets.

@t0mst0ne
Last active March 1, 2016 03:35
Show Gist options
  • Save t0mst0ne/34f78aab87ad2d07e271 to your computer and use it in GitHub Desktop.
Save t0mst0ne/34f78aab87ad2d07e271 to your computer and use it in GitHub Desktop.
大林慈濟 ER
#!/usr/bin/env ptyhon
#coding:UTF-8
import requests, json, os, re
from datetime import datetime
os.environ['TZ'] = 'ROC'
html = requests.get('http://app.tzuchi.com.tw/tchw/ERInfo_DL/ERInformation.aspx')
query = re.findall('<td>(.+?)</td>',html.text)
er = re.findall('>(.+?119.+?)</', html.text)[0]
full_reported = False if u'未' in er else True
query_time = query[4].split(' ')
if query_time[1] in u'\u4e0a\u5348':
P = "AM"
else:
P = "PM"
report ={}
report['full_reported'] = full_reported
report['pending_doctor'] = int(query[0])
report['pending_bed'] = int( query[1] )
report['pending_ward'] = int( query[2] )
report['pending_icu'] = int( query[3] )
report['update_time'] = datetime.strptime(str(query_time[0] +P+query_time[2]),'%Y/%m/%d%p%I:%M:%S').strftime('%s')
report['Hosptial_sn'] = '1240030514'
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