Toggle navigation
Toggle navigation
This project
Loading...
Sign in
황지민
/
Corona_Dust
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
황지민
2020-06-21 07:22:35 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cd64c3ec1edae9e2039239e1af4a673e0298128a
cd64c3ec
1 parent
55e1d3a8
Delete app.js
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
33 deletions
app.js
app.js
deleted
100644 → 0
View file @
55e1d3a
var
express
=
require
(
'express'
);
var
xml2js
=
require
(
'xml-js'
);
var
urlencode
=
require
(
'urlencode'
);
const
request
=
require
(
'request'
);
const
Dust_URL
=
"http://openapi.seoul.go.kr:8088/"
//미세먼지 api주소
const
Dust_URL2
=
"/xml/DailyAverageAirQuality/"
//미세먼지 api주소2
const
Dust_ServiceKey
=
"6b665775706a696d38396245624461"
//Dust url의 key값
const
Dust_Days
=
"1/5/20190520/"
//미세먼지 날짜
const
Dust_Place
=
urlencode
(
"강남구"
)
//측정한 장소
const
app
=
express
();
const
port
=
23023
;
const
url
=
Dust_URL
+
Dust_ServiceKey
+
Dust_URL2
+
Dust_Days
+
Dust_Place
;
request
(
url
,
function
(
error
,
res
,
body
)
{
if
(
error
){
console
.
log
(
'error=>${error}'
);
}
else
{
if
(
res
.
statusCode
==
200
)
{
var
result
=
body
;
//console.log(`body data => ${result}`);
var
xmlToJson
=
xml2js
.
xml2json
(
result
,
{
compact
:
true
,
spaces
:
4
});
//console.log(`xml to json => ${xmlToJson}`);
//console.log(typeof(JSON.parse(xmlToJson)));
xmlToJson2
=
JSON
.
parse
(
xmlToJson
);
console
.
log
(
"측정 날짜:"
,
xmlToJson2
[
"DailyAverageAirQuality"
][
"row"
][
"MSRDT_DE"
][
"_text"
]);
console
.
log
(
"측정 장소:"
,
xmlToJson2
[
"DailyAverageAirQuality"
][
"row"
][
"MSRSTE_NM"
][
"_text"
]);
console
.
log
(
"미세먼지 농도:"
,
xmlToJson2
[
"DailyAverageAirQuality"
][
"row"
][
"PM10"
][
"_text"
]);
}
}
});
\ No newline at end of file
Please
register
or
login
to post a comment