Skip to content

Instantly share code, notes, and snippets.

@t0mst0ne
Last active August 29, 2015 14:08
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 t0mst0ne/db06df0ee642bd76de24 to your computer and use it in GitHub Desktop.
Save t0mst0ne/db06df0ee642bd76de24 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#coding:UTF-8
# revised on 2014.10.31 due to website change
import requests, json, os, re
from datetime import datetime
os.environ['TZ'] = 'ROC'
html = requests.get('http://hlm.tzuchi.com.tw/html/hlinfos.html')
query = re.findall(u'<em>(.*?)</em>', html.text)
full_reported = False if u'N' in query[0] else True
query_time = re.findall(u'\xe6\x9c\x80\xe5\xbe\x8c\xe6\x9b\xb4\xe6\x96\xb0\xe6\x99\x82\xe9\x96\x93:(.*)', html.text)[0].split(' ')
update_time = str(int(query_time[0].split('/')[0])+1911)+ '/' + query_time[0].split('/')[1] + '/' + query_time[0].split('/')[2] + ' '+ query_time[1]
report ={}
report['full_reported'] = full_reported
report['pending_doctor'] = int(query[1])
report['pending_bed'] = int( query[2] )
report['pending_ward'] = int( query[3] )
report['pending_icu'] = int( query[4] )
report['update_time'] = datetime.strptime(update_time, '%Y/%m/%d %H:%M').strftime('%s')
report['hospital_sn'] = '1145010010'
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