Showing
3 changed files
with
253 additions
and
0 deletions
BusInfo.js
0 → 100644
1 | +let request = require('request'); | ||
2 | +let cheerio = require('cheerio'); | ||
3 | + | ||
4 | +const bus_url = 'http://apis.data.go.kr/6410000/busarrivalservice/getBusArrivalList'; | ||
5 | +const bus_key = 'RwxSWXH88b2bKOAT6Ot3FHorPZQW9omma0xYIjtJe0JIKe4DC7TjX7Uj6E1ArzYi2AvVETmPrAIYyY8FlL%2BfAA%3D%3D'; | ||
6 | +const stationID = '228000708'; | ||
7 | + | ||
8 | +const BusArrivalUrl = bus_url + '?servicekey=' + bus_key + '&stationId=' + stationID;// 사색의광장 정류장 버스 도착 정보 조회용 | ||
9 | +console.log(BusArrivalUrl); | ||
10 | + | ||
11 | +const _sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay)); | ||
12 | +var routeID = []; | ||
13 | +var BusNum = []; | ||
14 | +request(BusArrivalUrl, (err, res, body) => { | ||
15 | + var $ = cheerio.load(body, {decodeEntities: false}); | ||
16 | + | ||
17 | + $('busArrivalList').each(function(idx){ | ||
18 | + let route = $(this).find('routeId').text(); | ||
19 | + routeID.push(route); | ||
20 | + }) | ||
21 | + console.log(routeID); | ||
22 | +}) | ||
23 | + | ||
24 | +const route_url = 'http://apis.data.go.kr/6410000/busrouteservice/getBusRouteInfoItem'; | ||
25 | +const route_key = 'RwxSWXH88b2bKOAT6Ot3FHorPZQW9omma0xYIjtJe0JIKe4DC7TjX7Uj6E1ArzYi2AvVETmPrAIYyY8FlL%2BfAA%3D%3D'; | ||
26 | + | ||
27 | +var j = 0; | ||
28 | +function getBusNum(){ | ||
29 | + let BusRouteUrl = route_url + '?servicekey=' + route_key + '&routeId='; | ||
30 | + BusRouteUrl += routeID[j++]; | ||
31 | + console.log(BusRouteUrl); | ||
32 | + | ||
33 | + request(BusRouteUrl, (err, res, body) => { | ||
34 | + var $ = cheerio.load(body, {decodeEntities: false}); | ||
35 | + $('busRouteInfoItem').each(function(idx){ | ||
36 | + let num = $(this).find('routeName').text(); | ||
37 | + BusNum.push(num); | ||
38 | + console.log(num); | ||
39 | + }) | ||
40 | + }) | ||
41 | +} | ||
42 | + | ||
43 | +function useFor(){ | ||
44 | + for(var i=0; i<routeID.length; i++){ | ||
45 | + setTimeout(getBusNum, 1000); | ||
46 | + } | ||
47 | +} | ||
48 | +setTimeout(useFor, 500); |
package-lock.json
0 → 100644
1 | +{ | ||
2 | + "name": "bustime", | ||
3 | + "version": "1.0.0", | ||
4 | + "lockfileVersion": 1, | ||
5 | + "requires": true, | ||
6 | + "dependencies": { | ||
7 | + "amdefine": { | ||
8 | + "version": "1.0.1", | ||
9 | + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", | ||
10 | + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=" | ||
11 | + }, | ||
12 | + "async": { | ||
13 | + "version": "0.2.10", | ||
14 | + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", | ||
15 | + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=" | ||
16 | + }, | ||
17 | + "boolbase": { | ||
18 | + "version": "1.0.0", | ||
19 | + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", | ||
20 | + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" | ||
21 | + }, | ||
22 | + "cheerio": { | ||
23 | + "version": "1.0.0-rc.9", | ||
24 | + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.9.tgz", | ||
25 | + "integrity": "sha512-QF6XVdrLONO6DXRF5iaolY+odmhj2CLj+xzNod7INPWMi/x9X4SOylH0S/vaPpX+AUU6t04s34SQNh7DbkuCng==", | ||
26 | + "requires": { | ||
27 | + "cheerio-select": "^1.4.0", | ||
28 | + "dom-serializer": "^1.3.1", | ||
29 | + "domhandler": "^4.2.0", | ||
30 | + "htmlparser2": "^6.1.0", | ||
31 | + "parse5": "^6.0.1", | ||
32 | + "parse5-htmlparser2-tree-adapter": "^6.0.1", | ||
33 | + "tslib": "^2.2.0" | ||
34 | + } | ||
35 | + }, | ||
36 | + "cheerio-select": { | ||
37 | + "version": "1.4.0", | ||
38 | + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.4.0.tgz", | ||
39 | + "integrity": "sha512-sobR3Yqz27L553Qa7cK6rtJlMDbiKPdNywtR95Sj/YgfpLfy0u6CGJuaBKe5YE/vTc23SCRKxWSdlon/w6I/Ew==", | ||
40 | + "requires": { | ||
41 | + "css-select": "^4.1.2", | ||
42 | + "css-what": "^5.0.0", | ||
43 | + "domelementtype": "^2.2.0", | ||
44 | + "domhandler": "^4.2.0", | ||
45 | + "domutils": "^2.6.0" | ||
46 | + } | ||
47 | + }, | ||
48 | + "css-select": { | ||
49 | + "version": "4.1.2", | ||
50 | + "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.1.2.tgz", | ||
51 | + "integrity": "sha512-nu5ye2Hg/4ISq4XqdLY2bEatAcLIdt3OYGFc9Tm9n7VSlFBcfRv0gBNksHRgSdUDQGtN3XrZ94ztW+NfzkFSUw==", | ||
52 | + "requires": { | ||
53 | + "boolbase": "^1.0.0", | ||
54 | + "css-what": "^5.0.0", | ||
55 | + "domhandler": "^4.2.0", | ||
56 | + "domutils": "^2.6.0", | ||
57 | + "nth-check": "^2.0.0" | ||
58 | + } | ||
59 | + }, | ||
60 | + "css-what": { | ||
61 | + "version": "5.0.0", | ||
62 | + "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.0.tgz", | ||
63 | + "integrity": "sha512-qxyKHQvgKwzwDWC/rGbT821eJalfupxYW2qbSJSAtdSTimsr/MlaGONoNLllaUPZWf8QnbcKM/kPVYUQuEKAFA==" | ||
64 | + }, | ||
65 | + "dom-serializer": { | ||
66 | + "version": "1.3.2", | ||
67 | + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", | ||
68 | + "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", | ||
69 | + "requires": { | ||
70 | + "domelementtype": "^2.0.1", | ||
71 | + "domhandler": "^4.2.0", | ||
72 | + "entities": "^2.0.0" | ||
73 | + } | ||
74 | + }, | ||
75 | + "domelementtype": { | ||
76 | + "version": "2.2.0", | ||
77 | + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", | ||
78 | + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==" | ||
79 | + }, | ||
80 | + "domhandler": { | ||
81 | + "version": "4.2.0", | ||
82 | + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz", | ||
83 | + "integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==", | ||
84 | + "requires": { | ||
85 | + "domelementtype": "^2.2.0" | ||
86 | + } | ||
87 | + }, | ||
88 | + "domutils": { | ||
89 | + "version": "2.6.0", | ||
90 | + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.6.0.tgz", | ||
91 | + "integrity": "sha512-y0BezHuy4MDYxh6OvolXYsH+1EMGmFbwv5FKW7ovwMG6zTPWqNPq3WF9ayZssFq+UlKdffGLbOEaghNdaOm1WA==", | ||
92 | + "requires": { | ||
93 | + "dom-serializer": "^1.0.1", | ||
94 | + "domelementtype": "^2.2.0", | ||
95 | + "domhandler": "^4.2.0" | ||
96 | + } | ||
97 | + }, | ||
98 | + "entities": { | ||
99 | + "version": "2.2.0", | ||
100 | + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", | ||
101 | + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==" | ||
102 | + }, | ||
103 | + "htmlparser2": { | ||
104 | + "version": "6.1.0", | ||
105 | + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", | ||
106 | + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", | ||
107 | + "requires": { | ||
108 | + "domelementtype": "^2.0.1", | ||
109 | + "domhandler": "^4.0.0", | ||
110 | + "domutils": "^2.5.2", | ||
111 | + "entities": "^2.0.0" | ||
112 | + } | ||
113 | + }, | ||
114 | + "nth-check": { | ||
115 | + "version": "2.0.0", | ||
116 | + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz", | ||
117 | + "integrity": "sha512-i4sc/Kj8htBrAiH1viZ0TgU8Y5XqCaV/FziYK6TBczxmeKm3AEFWqqF3195yKudrarqy7Zu80Ra5dobFjn9X/Q==", | ||
118 | + "requires": { | ||
119 | + "boolbase": "^1.0.0" | ||
120 | + } | ||
121 | + }, | ||
122 | + "optimist": { | ||
123 | + "version": "0.3.7", | ||
124 | + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz", | ||
125 | + "integrity": "sha1-yQlBrVnkJzMokjB00s8ufLxuwNk=", | ||
126 | + "requires": { | ||
127 | + "wordwrap": "~0.0.2" | ||
128 | + } | ||
129 | + }, | ||
130 | + "parse5": { | ||
131 | + "version": "6.0.1", | ||
132 | + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", | ||
133 | + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==" | ||
134 | + }, | ||
135 | + "parse5-htmlparser2-tree-adapter": { | ||
136 | + "version": "6.0.1", | ||
137 | + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz", | ||
138 | + "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==", | ||
139 | + "requires": { | ||
140 | + "parse5": "^6.0.1" | ||
141 | + } | ||
142 | + }, | ||
143 | + "require": { | ||
144 | + "version": "2.4.20", | ||
145 | + "resolved": "https://registry.npmjs.org/require/-/require-2.4.20.tgz", | ||
146 | + "integrity": "sha1-Zstrqqu2XeinHXk/XGX9GE83mLY=", | ||
147 | + "requires": { | ||
148 | + "std": "0.1.40", | ||
149 | + "uglify-js": "2.3.0" | ||
150 | + } | ||
151 | + }, | ||
152 | + "source-map": { | ||
153 | + "version": "0.1.43", | ||
154 | + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", | ||
155 | + "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", | ||
156 | + "requires": { | ||
157 | + "amdefine": ">=0.0.4" | ||
158 | + } | ||
159 | + }, | ||
160 | + "std": { | ||
161 | + "version": "0.1.40", | ||
162 | + "resolved": "https://registry.npmjs.org/std/-/std-0.1.40.tgz", | ||
163 | + "integrity": "sha1-Nnil9lCU2eG2teJu2/wCErg0K3E=" | ||
164 | + }, | ||
165 | + "tslib": { | ||
166 | + "version": "2.2.0", | ||
167 | + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz", | ||
168 | + "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==" | ||
169 | + }, | ||
170 | + "uglify-js": { | ||
171 | + "version": "2.3.0", | ||
172 | + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.3.0.tgz", | ||
173 | + "integrity": "sha1-LN7BbTeKiituz7aYl4TPi3rlSR8=", | ||
174 | + "requires": { | ||
175 | + "async": "~0.2.6", | ||
176 | + "optimist": "~0.3.5", | ||
177 | + "source-map": "~0.1.7" | ||
178 | + } | ||
179 | + }, | ||
180 | + "wordwrap": { | ||
181 | + "version": "0.0.3", | ||
182 | + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", | ||
183 | + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" | ||
184 | + } | ||
185 | + } | ||
186 | +} |
package.json
0 → 100644
1 | +{ | ||
2 | + "name": "bustime", | ||
3 | + "version": "1.0.0", | ||
4 | + "description": "", | ||
5 | + "main": "BusInfo.js", | ||
6 | + "scripts": { | ||
7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | + }, | ||
9 | + "repository": { | ||
10 | + "type": "git", | ||
11 | + "url": "http://khuhub.khu.ac.kr/2020105677/BusTime.git" | ||
12 | + }, | ||
13 | + "author": "", | ||
14 | + "license": "ISC", | ||
15 | + "dependencies": { | ||
16 | + "cheerio": "^1.0.0-rc.9", | ||
17 | + "require": "^2.4.20" | ||
18 | + } | ||
19 | +} |
-
Please register or login to post a comment