Showing
1 changed file
with
17 additions
and
4 deletions
1 | +const { query } = require('express'); | ||
2 | +const express = require('express'); | ||
3 | +const app = express(); | ||
1 | const request = require('request'); | 4 | const request = require('request'); |
2 | const convert = require("xml-js"); | 5 | const convert = require("xml-js"); |
3 | 6 | ||
4 | var url = 'http://apis.data.go.kr/B552657/ErmctInfoInqireService/getEmrrmRltmUsefulSckbdInfoInqire'; | 7 | var url = 'http://apis.data.go.kr/B552657/ErmctInfoInqireService/getEmrrmRltmUsefulSckbdInfoInqire'; |
5 | var queryParams = '?' + encodeURIComponent('serviceKey') + '=52tXHgaW46YUpGn9k0r3IQrduIl6kBOl3Ta8Idra1%2BpPMYhL4qVCDu9itW8FVbDtMF4f9LAT9NJXEx7pvEJv%2FQ%3D%3D'; /* Service Key*/ | 8 | var queryParams = '?' + encodeURIComponent('serviceKey') + '=52tXHgaW46YUpGn9k0r3IQrduIl6kBOl3Ta8Idra1%2BpPMYhL4qVCDu9itW8FVbDtMF4f9LAT9NJXEx7pvEJv%2FQ%3D%3D'; /* Service Key*/ |
6 | -queryParams += '&' + encodeURIComponent('STAGE1') + '=' + encodeURIComponent('¼¿ïƯº°½Ã'); /* */ | 9 | + |
7 | -queryParams += '&' + encodeURIComponent('STAGE2') + '=' + encodeURIComponent('°³²±¸'); /* */ | 10 | +queryParams += '&' + encodeURIComponent('STAGE1') + '=' + '%EC%84%9C%EC%9A%B8%ED%8A%B9%EB%B3%84%EC%8B%9C'; /* */ |
11 | +queryParams += '&' + encodeURIComponent('STAGE2') + '=' + '%EA%B0%95%EB%82%A8%EA%B5%AC'; /* */ | ||
8 | queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */ | 12 | queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */ |
9 | queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('10'); /* */ | 13 | queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('10'); /* */ |
10 | 14 | ||
15 | +console.log(url+queryParams); | ||
16 | + | ||
11 | request({ | 17 | request({ |
12 | url: url + queryParams, | 18 | url: url + queryParams, |
13 | method: 'GET' | 19 | method: 'GET' |
... | @@ -15,5 +21,12 @@ request({ | ... | @@ -15,5 +21,12 @@ request({ |
15 | if(err){ | 21 | if(err){ |
16 | console.log(`err => ${err}`) | 22 | console.log(`err => ${err}`) |
17 | } | 23 | } |
18 | - console.log(convert.xml2js(body)); | ||
19 | -}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
24 | + else{ | ||
25 | + var result = body | ||
26 | + console.log(`body data => ${result}`) | ||
27 | + var xmlTojson = convert.xml2json(result, {compact: true, spaces:4}); | ||
28 | + console.log(`xml to json => ${xmlTojson}`) | ||
29 | + } | ||
30 | + | ||
31 | + } | ||
32 | +); | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment