Skip to content

Instantly share code, notes, and snippets.

@lanfon72
Created March 1, 2016 04:12
Show Gist options
  • Select an option

  • Save lanfon72/e8cc945d48b7192164d2 to your computer and use it in GitHub Desktop.

Select an option

Save lanfon72/e8cc945d48b7192164d2 to your computer and use it in GitHub Desktop.
tonyung hospital ER.
# !/usr/bin/env ptyhon
# coding:UTF-8
import requests, json, re
from datetime import datetime
html = requests.get('http://www.tyh.com.tw/ERActive/ERBMEIMS.aspx')
keys = ['pending_doctor', 'pending_bed', 'pending_ward', 'pending_icu']
pending = re.findall('".+">(.+?)</span>', html.text)
values = [int(ele) for ele in pending[1:5]]
report = {k:v for k, v in zip(keys, values)}
report['hospital_sn'] = "1533050039"
report['full_reported'] = False if u'未通報' in pending[0] else True
upt = re.findall(u'(\d+) [年|月|日]', pending[-2])
upt[0] = str(int(upt[0]) + 1911)
upt = '/'.join(upt) + " " +pending[-1].replace(u":",':')
report['update_time'] = datetime.strptime(upt, "%Y/%m/%d %H:%M").strftime("%s")
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