홍용민

사색의광장 버스 정보 읽기 베이스

let request = require('request');
let cheerio = require('cheerio');
const bus_url = 'http://apis.data.go.kr/6410000/busarrivalservice/getBusArrivalList';
const bus_key = 'RwxSWXH88b2bKOAT6Ot3FHorPZQW9omma0xYIjtJe0JIKe4DC7TjX7Uj6E1ArzYi2AvVETmPrAIYyY8FlL%2BfAA%3D%3D';
const stationID = '228000708';
const BusArrivalUrl = bus_url + '?servicekey=' + bus_key + '&stationId=' + stationID;// 사색의광장 정류장 버스 도착 정보 조회용
console.log(BusArrivalUrl);
const _sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
var routeID = [];
var BusNum = [];
request(BusArrivalUrl, (err, res, body) => {
var $ = cheerio.load(body, {decodeEntities: false});
$('busArrivalList').each(function(idx){
let route = $(this).find('routeId').text();
routeID.push(route);
})
console.log(routeID);
})
const route_url = 'http://apis.data.go.kr/6410000/busrouteservice/getBusRouteInfoItem';
const route_key = 'RwxSWXH88b2bKOAT6Ot3FHorPZQW9omma0xYIjtJe0JIKe4DC7TjX7Uj6E1ArzYi2AvVETmPrAIYyY8FlL%2BfAA%3D%3D';
var j = 0;
function getBusNum(){
let BusRouteUrl = route_url + '?servicekey=' + route_key + '&routeId=';
BusRouteUrl += routeID[j++];
console.log(BusRouteUrl);
request(BusRouteUrl, (err, res, body) => {
var $ = cheerio.load(body, {decodeEntities: false});
$('busRouteInfoItem').each(function(idx){
let num = $(this).find('routeName').text();
BusNum.push(num);
console.log(num);
})
})
}
function useFor(){
for(var i=0; i<routeID.length; i++){
setTimeout(getBusNum, 1000);
}
}
setTimeout(useFor, 500);
{
"name": "bustime",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"amdefine": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU="
},
"async": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
"integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E="
},
"boolbase": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
},
"cheerio": {
"version": "1.0.0-rc.9",
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.9.tgz",
"integrity": "sha512-QF6XVdrLONO6DXRF5iaolY+odmhj2CLj+xzNod7INPWMi/x9X4SOylH0S/vaPpX+AUU6t04s34SQNh7DbkuCng==",
"requires": {
"cheerio-select": "^1.4.0",
"dom-serializer": "^1.3.1",
"domhandler": "^4.2.0",
"htmlparser2": "^6.1.0",
"parse5": "^6.0.1",
"parse5-htmlparser2-tree-adapter": "^6.0.1",
"tslib": "^2.2.0"
}
},
"cheerio-select": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.4.0.tgz",
"integrity": "sha512-sobR3Yqz27L553Qa7cK6rtJlMDbiKPdNywtR95Sj/YgfpLfy0u6CGJuaBKe5YE/vTc23SCRKxWSdlon/w6I/Ew==",
"requires": {
"css-select": "^4.1.2",
"css-what": "^5.0.0",
"domelementtype": "^2.2.0",
"domhandler": "^4.2.0",
"domutils": "^2.6.0"
}
},
"css-select": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-4.1.2.tgz",
"integrity": "sha512-nu5ye2Hg/4ISq4XqdLY2bEatAcLIdt3OYGFc9Tm9n7VSlFBcfRv0gBNksHRgSdUDQGtN3XrZ94ztW+NfzkFSUw==",
"requires": {
"boolbase": "^1.0.0",
"css-what": "^5.0.0",
"domhandler": "^4.2.0",
"domutils": "^2.6.0",
"nth-check": "^2.0.0"
}
},
"css-what": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.0.tgz",
"integrity": "sha512-qxyKHQvgKwzwDWC/rGbT821eJalfupxYW2qbSJSAtdSTimsr/MlaGONoNLllaUPZWf8QnbcKM/kPVYUQuEKAFA=="
},
"dom-serializer": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
"integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==",
"requires": {
"domelementtype": "^2.0.1",
"domhandler": "^4.2.0",
"entities": "^2.0.0"
}
},
"domelementtype": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz",
"integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A=="
},
"domhandler": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz",
"integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==",
"requires": {
"domelementtype": "^2.2.0"
}
},
"domutils": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.6.0.tgz",
"integrity": "sha512-y0BezHuy4MDYxh6OvolXYsH+1EMGmFbwv5FKW7ovwMG6zTPWqNPq3WF9ayZssFq+UlKdffGLbOEaghNdaOm1WA==",
"requires": {
"dom-serializer": "^1.0.1",
"domelementtype": "^2.2.0",
"domhandler": "^4.2.0"
}
},
"entities": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz",
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A=="
},
"htmlparser2": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz",
"integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==",
"requires": {
"domelementtype": "^2.0.1",
"domhandler": "^4.0.0",
"domutils": "^2.5.2",
"entities": "^2.0.0"
}
},
"nth-check": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz",
"integrity": "sha512-i4sc/Kj8htBrAiH1viZ0TgU8Y5XqCaV/FziYK6TBczxmeKm3AEFWqqF3195yKudrarqy7Zu80Ra5dobFjn9X/Q==",
"requires": {
"boolbase": "^1.0.0"
}
},
"optimist": {
"version": "0.3.7",
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz",
"integrity": "sha1-yQlBrVnkJzMokjB00s8ufLxuwNk=",
"requires": {
"wordwrap": "~0.0.2"
}
},
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
},
"parse5-htmlparser2-tree-adapter": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz",
"integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==",
"requires": {
"parse5": "^6.0.1"
}
},
"require": {
"version": "2.4.20",
"resolved": "https://registry.npmjs.org/require/-/require-2.4.20.tgz",
"integrity": "sha1-Zstrqqu2XeinHXk/XGX9GE83mLY=",
"requires": {
"std": "0.1.40",
"uglify-js": "2.3.0"
}
},
"source-map": {
"version": "0.1.43",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz",
"integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=",
"requires": {
"amdefine": ">=0.0.4"
}
},
"std": {
"version": "0.1.40",
"resolved": "https://registry.npmjs.org/std/-/std-0.1.40.tgz",
"integrity": "sha1-Nnil9lCU2eG2teJu2/wCErg0K3E="
},
"tslib": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz",
"integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w=="
},
"uglify-js": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.3.0.tgz",
"integrity": "sha1-LN7BbTeKiituz7aYl4TPi3rlSR8=",
"requires": {
"async": "~0.2.6",
"optimist": "~0.3.5",
"source-map": "~0.1.7"
}
},
"wordwrap": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",
"integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc="
}
}
}
{
"name": "bustime",
"version": "1.0.0",
"description": "",
"main": "BusInfo.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "http://khuhub.khu.ac.kr/2020105677/BusTime.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"cheerio": "^1.0.0-rc.9",
"require": "^2.4.20"
}
}