Skip to content

Instantly share code, notes, and snippets.

@cornguo

cornguo/cmuh.php Secret

Last active March 3, 2017 03:54
Show Gist options
  • Save cornguo/e357bade74728a63d7d6 to your computer and use it in GitHub Desktop.
Save cornguo/e357bade74728a63d7d6 to your computer and use it in GitHub Desktop.
<?php
date_default_timezone_set('Asia/Taipei');
$ch = curl_init('http://61.66.117.8/EmrCount/Default.aspx');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$pattern = '/<td.*>.*<(font|span).*>(.*)<\/.*>/Uum';
$match = array();
preg_match_all($pattern, $data, $match);
$time = $match[2][5];
$time = str_replace(
array('上', '下', '午'),
array('A', 'P', 'M'),
$match[2][10]
);
$time = explode(' ', $time);
$return = array(
'hospital_sn' => '1317050017',
'update_time' => strtotime($time[0] . ' ' . $time[2] . $time[1]),
'full_reported' => ('是' === $match[2][1])? true:false,
'pending_doctor' => intval($match[2][3]),
'pending_bed' => intval($match[2][5]),
'pending_ward' => intval($match[2][7]),
'pending_icu' => intval($match[2][9])
);
echo json_encode($return);
@t0mst0ne
Copy link

t0mst0ne commented Mar 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment