Created
March 1, 2016 04:12
-
-
Save lanfon72/e8cc945d48b7192164d2 to your computer and use it in GitHub Desktop.
tonyung hospital ER.
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 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