Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이혜인
/
Multiplex_Ticketing_Platform
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이혜인
2022-05-16 22:12:32 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
00f794acbfd096fc01cabffc8d7f770a7a9d726c
00f794ac
1 parent
2b3e19ce
영화 검색 API_json 파싱
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
SearchAPI/app.js
SearchAPI/package.json
SearchAPI/app.js
0 → 100644
View file @
00f794a
var
express
=
require
(
'express'
);
var
config
=
require
(
'./config.json'
)
var
app
=
express
();
var
client_id
=
config
.
SearchClientID
;
var
client_secret
=
config
.
SearchClientSecret
;
var
SearchWord
;
var
MovieSearchParse
;
var
movietitlelist
;
var
movielist
;
app
.
post
(
'/search/movie'
,
function
(
req
,
res
)
{
SearchWord
=
req
.
query
.
query
;
res
.
send
(
SearchWord
)})
app
.
get
(
'/search/movie'
,
function
(
req
,
res
)
{
var
api_url
=
'https://openapi.naver.com/v1/search/movie?query='
+
encodeURI
(
SearchWord
);
var
request
=
require
(
'request'
);
var
options
=
{
url
:
api_url
,
headers
:
{
'X-Naver-Client-Id'
:
client_id
,
'X-Naver-Client-Secret'
:
client_secret
}
};
request
.
get
(
options
,
function
(
error
,
response
,
body
)
{
if
(
!
error
&&
response
.
statusCode
==
200
)
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/json;charset=utf-8'
});
MovieSearchParse
=
JSON
.
parse
(
body
);
//movietitlelist =MovieSearchParse.items[0].title.replace(/<[^>]*>?/g, '');
movietitlelist
=
MovieSearchParse
.
items
.
map
((
x
)
=>
{
x
.
title
=
x
.
title
.
replace
(
/<
[^
>
]
*>
?
/g
,
''
);
return
x
.
title
;
});
movielist
=
MovieSearchParse
.
items
.
map
((
x
)
=>
{
x
.
title
=
x
.
title
.
replace
(
/<
[^
>
]
*>
?
/g
,
''
);
return
x
;
});
console
.
log
(
movielist
);
res
.
end
(
body
);
}
else
{
res
.
status
(
response
.
statusCode
).
end
();
console
.
log
(
'error = '
+
response
.
statusCode
);
}
});
});
app
.
listen
(
3000
,
function
()
{
console
.
log
(
'http://127.0.0.1:3000/search/movie?query=검색어 app listening on port 3000!'
);
});
SearchAPI/package.json
0 → 100644
View file @
00f794a
{
"dependencies"
:
{
"express"
:
"^4.18.1"
,
"request"
:
"^2.88.2"
}
}
Please
register
or
login
to post a comment