-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathexcelNPSN.php
59 lines (55 loc) · 1.69 KB
/
excelNPSN.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
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/php
<?php
/**
* https://github.com/egin10
* Get Data from url
* @param $file
* @return array
* url : https://referensi.data.kemdikbud.go.id/tabs.php?npsn=NPSN_SEKOLAH
*/
ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);
date_default_timezone_set("Asia/Jakarta");
require_once __DIR__.'/src/SimpleXLSX.php';
require_once __DIR__.'/src/func.php';
$n = 1;
if ( $xlsx = SimpleXLSX::parse(__DIR__.'/check-npsn.xlsx') ) {
// print_r( $xlsx->rows() );
$t = count($xlsx->rows());
if($t < 3) {
echo "Silahkan isi list NPSN di file check-npsn.xlsx\n";
} else {
echo "Daftar Sekolah yang di check\n";
for($i=2; $i<$t; $i++) {
$getData = new GetData;
$url = "https://referensi.data.kemdikbud.go.id/tabs.php?npsn=".trim($xlsx->rows()[$i][0]);
$ch = curl_init($url);
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true]);
$get = curl_exec($ch);
$res = $getData->checkNPSN($get);
curl_close($ch);
// print_r($res);
echo "======================================\n";
echo "No. ".$n."\n";
echo "NPSN Excel : ".$xlsx->rows()[$i][0]."\n";
if($res == '') {
echo "Data tidak ditemukan.\n";
}else{
echo "NPSN Dapodik : ".$res['npsn']."\n";
echo "Nama Sekolah : ".$res['nama']."\n";
echo "Alamat : ".$res['alamat']."\n";
echo "Kecamatan : ".$res['kecamatan']."\n";
echo "Kab/Kota : ".$res['kabupaten_kota']."\n";
echo "Provinsi : ".$res['provinsi']."\n";
echo "Status : ".$res['status']."\n";
echo "Jenjang : ".$res['jenjang']."\n";
echo "Akreditasi : ".$res['akreditasi']."\n";
echo "Tgl SK Akreditasi : ".$res['tgl_sk_akreditasi']."\n";
}
$n++;
unset($getData);
}
}
} else {
echo SimpleXLSX::parseError();
}