Skip to content

Instantly share code, notes, and snippets.

@t0mst0ne
Last active January 9, 2016 14:46
Show Gist options
  • Select an option

  • Save t0mst0ne/5686e8581393339b2a7e to your computer and use it in GitHub Desktop.

Select an option

Save t0mst0ne/5686e8581393339b2a7e 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://www.scmh.org.tw/FirstAid.aspx?Kind=2')
reported = re.findall(u'(.*119.*)',html.text)
full_reported = False if u'未' in reported[1] else True
pending_doctor = re.findall(u'等待看診人數.*"?>(\d+?)</', html.text)
pending_bed = re.findall(u'等待推床人數.*"?>(\d+?)</', html.text)
pending_ward = re.findall(u'等待住院人數.*"?>(\d+?)</', html.text)
pending_icu = re.findall(u'等待加護病床人數.*"?>(\d+?)</',html.text)
#query_time = re.findall(u'上次更新時間.*><font.*"?>(.+?)</font',html.text)
report ={}
report['full_reported'] = full_reported
report['pending_doctor'] = int(pending_doctor[0])
report['pending_bed'] = int( pending_bed[0] )
report['pending_ward'] = int( pending_ward[0] )
report['pending_icu'] = int( pending_icu[0])
#report['update_time'] = datetime.strptime(query_time[0], '%Y/%m/%d').strftime('%s')
report['update_time'] = datetime.now().strftime('%s')
report['hospital_sn'] = '0937010019'
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