forked from kokonior/PHP-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFaizmuzaki_getBedCovid.php
48 lines (43 loc) · 1.75 KB
/
Faizmuzaki_getBedCovid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
error_reporting(0);
date_default_timezone_set('Asia/Jakarta');
echo "source:yankes.kemkes.go.id
time ".date("h:i:sa")."\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://yankes.kemkes.go.id/app/siranap/rumah_sakit?jenis=1&propinsi=18prop&kabkota=');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$headers = array();
$headers[] = 'Host: yankes.kemkes.go.id';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36';
$headers[] = 'Sec-Fetch-Site: same-origin';
$headers[] = 'Sec-Fetch-Dest: document';
$headers[] = 'Referer: https://yankes.kemkes.go.id/app/siranap/rumah_sakit?jenis=1&propinsi=18prop&kabkota=1871';
$headers[] = 'Accept-Language: en-US,en;q=0.9';
$headers[] = 'Connection: close';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$pisah = explode('<div class="col-md-10 offset-md-1">', $result);
$content = strip_tags($pisah[1]);
$output = preg_replace('!\s+!', ' ', $content);
header('Content-Type: application/json');
$explode1 = explode('Bed Detail', $output);
foreach ($explode1 as $data) {
preg_match('/(.*?) INFO/', $data, $namars);
preg_match('/    (.*?) /', $data,$nomorrs);
preg_match('/diupdate(.*?) yang lalu/', $data,$lastupdate);
preg_match('/INFO IGD KHUSUS COVID(.*?) diupdate/', $data,$bedrs);
if($namars[1]== "") {
echo "";
}else{
print_r(array('nama_rs' => $namars[1],
'nomor_rs' => $nomorrs[1],
'last_update' => $lastupdate[1],
'kasur_tersedia' => $bedrs[1],
));
}
}
?>