Last active
August 29, 2015 14:08
-
-
Save t0mst0ne/db06df0ee642bd76de24 to your computer and use it in GitHub Desktop.
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 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