Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cornguo
Last active August 29, 2015 14:04
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 cornguo/c3b97701f25acabb37fb to your computer and use it in GitHub Desktop.
Save cornguo/c3b97701f25acabb37fb to your computer and use it in GitHub Desktop.
<?php
date_default_timezone_set('Asia/Taipei');
$ch = curl_init('http://www.vghtc.gov.tw/GipOpenWeb/wSite/sp?xdUrl=/wSite/query/Doctor/GetEmgBedInform.jsp&ctNode=55658&mp=1&idPath=213_55658');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$data = strstr($data, '<span>急診即時資訊</span>');
$pattern = '/<td.*>.*([^>]*)人?<\/.*<\/td>/Uum';
$match = array();
preg_match_all($pattern, $data, $match);
$return = array(
'hospital_sn' => '0617060018',
'update_time' => time(),
'full_reported' => ('否' === $match[1][1])? false:true,
'pending_doctor' => intval($match[1][3]) + intval($match[1][5]) + intval($match[1][7]),
'pending_bed' => intval($match[1][9]),
'pending_ward' => intval($match[1][11]),
'pending_icu' => intval($match[1][13])
);
echo json_encode($return);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment