Last active
March 21, 2017 05:13
-
-
Save jybaek/bd26a5c0208ea2be982c025b67ac6669 to your computer and use it in GitHub Desktop.
경기버스 정보 크롤링
This file contains 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
<?php | |
$url = "http://www.gbis.go.kr/gbis2014/schBusAPI.action"; | |
function curl($data) | |
{ | |
global $url; | |
//global $post; | |
//global $data; | |
//global $ref_url; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_POST, TRUE); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
ob_start(); | |
$res = curl_exec ($ch); | |
echo $res; | |
return 1; | |
ob_end_clean(); | |
curl_close($ch); | |
unset($ch); | |
} | |
/* FIXME. Change serchKeyword */ | |
$serchKeyword = "49540"; | |
$result = curl("cmd=searchAllJson&searchKeyword=$serchKeyword&pageOfRoute=1&pageOfBus=1&pageOfSubway=1&pageOfPOI=1&searchGubun=undefined"); | |
/* result에서 stationId 파싱 */ | |
// .... | |
/* FIXME. Change stationId */ | |
$stationId = "222001670"; | |
$result = curl("cmd=searchBusStationJson&stationId=$stationId"); | |
// predictTime1, predictTime2 | |
// locationNo1, locationNo2 | |
echo $result; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment