Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김서연
/
Corona_Vaccination_Medical_Institution
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김서연
2021-05-18 22:19:25 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f5e21bd973248d9bba31f3d431e5d40a9466ebbe
f5e21bd9
1 parent
639438b3
api데이터에 파싱테스트
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
app.js
app.js
View file @
f5e21bd
...
...
@@ -13,28 +13,33 @@ app.use(express.static('public'));
const
$base_url
=
`https://api.odcloud.kr/api/apnmOrg/v1/list`
;
const
$key
=
'4US0H%2BXj%2BmS8IR4YL0%2BUb9H4CcbTr92QxhYULfOEz1DT%2BZaaos4sRfNh6cmAD2Icli862Ysc31%2BaE4pWywDBIA%3D%3D'
;
//임시
//임시
매개변수
const
$page
=
1
;
const
$perPage
=
10
;
const
$api_url
=
$base_url
+
'?
returnType=XML&
serviceKey='
+
$key
+
'&page='
+
$page
+
'&perPage='
+
$perPage
;
const
$api_url
=
$base_url
+
'?serviceKey='
+
$key
+
'&page='
+
$page
+
'&perPage='
+
$perPage
;
console
.
log
(
$api_url
);
//해당 URL로 요청
request
(
$api_url
,
function
(
err
,
res
,
body
){
if
(
err
)
throw
err
;
var
obj
=
JSON
.
parse
(
body
);
// console.log(obj);
for
(
var
i
=
0
;
i
<
obj
.
data
.
length
;
i
++
){
let
name
=
obj
.
data
[
i
].
orgnm
;
let
location
=
obj
.
data
[
i
].
orgZipaddr
;
console
.
log
(
`기관명:
${
name
}
, 위치:
${
location
}
\n`
);
}
// res.render('main', {title: 'misae', data:data, pm10:pm10})
})
app
.
listen
(
3000
,
function
(){
console
.
log
(
'Connected 3000 port!'
);
});
request
(
$api_url
,
function
(
err
,
res
,
body
){
$
=
cheerio
.
load
(
body
);
const
$infoList
=
$
(
'item'
)
console
.
log
(
$infoList
.
html
());
console
.
log
(
$infoList
.
length
);
// let name = $infoList.find('orgnm').text();
// let location = $infoList.find('orgZipaddr').text();
// console.log(`기관명: ${name}, 위치: ${location}`);
})
app
.
post
(
'/search'
,
function
(
req
,
res
){
res
.
send
(
'내가 검색한 지역은 '
+
req
.
body
.
region
);
})
...
...
Please
register
or
login
to post a comment