Toggle navigation
Toggle navigation
This project
Loading...
Sign in
유승근
/
Computer-part-Recommand
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
1
Network
Create a new issue
Commits
Issue Boards
Authored by
Yuseunggeun
2020-06-24 20:45:25 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
176830dfe0e93c1cae3a1981c9d791b2d70323ab
176830df
1 parent
472ac510
네이버 api 키워드 검색
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
4 deletions
routes/index.js
routes/main.js
views/main.ejs
routes/index.js
View file @
176830d
...
...
@@ -3,6 +3,10 @@ var request = require("request");
var
express
=
require
(
"express"
);
var
router
=
express
.
Router
();
var
client_id
=
'HH0lbvfI3QtlyR7e9tkw'
;
var
client_secret
=
'mvPTEsNs7L'
;
var
url
=
"https://www.videocardbenchmark.net/gpu_value.html#all-time-value"
;
//var Graphic_card = [];
//var Price = [];
...
...
@@ -54,6 +58,7 @@ router.get('/rank',function(req,res){
router
.
post
(
'/search'
,
function
(
req
,
res
,
next
){
console
.
log
(
'Money : '
+
req
.
body
.
money
);
console
.
log
(
req
.
body
);
var
Money
=
req
.
body
.
money
;
//입력한 예산
var
Searchlist
=
new
Array
();
var
Searchcount
=
0
;
...
...
@@ -78,4 +83,24 @@ router.post('/search',function(req,res,next){
});
router
.
post
(
'/shop'
,
function
(
req
,
res
)
{
var
keyword
=
req
.
body
.
word
;
req
.
query
.
query
=
keyword
;
var
api_url
=
'https://openapi.naver.com/v1/search/shop?query='
+
encodeURI
(
req
.
query
.
query
);
// json 결과
// var api_url = 'https://openapi.naver.com/v1/search/shop.xml?query=' + encodeURI(req.query.query); // xml 결과
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'
});
res
.
end
(
body
);
}
else
{
res
.
status
(
response
.
statusCode
).
end
();
console
.
log
(
'error = '
+
response
.
statusCode
);
}
});
});
module
.
exports
=
router
;
\ No newline at end of file
...
...
routes/main.js
View file @
176830d
/*
var express = require('express');
var app = express();
var client_id = 'HH0lbvfI3QtlyR7e9tkw';
var client_secret = 'mvPTEsNs7L';
app
.
get
(
'/search/blog'
,
function
(
req
,
res
)
{
app.get('/search/shop', function (req, res) {
req.query.query = req.body.keyword;
var api_url = 'https://openapi.naver.com/v1/search/shop?query=' + encodeURI(req.query.query); // json 결과
// var api_url = 'https://openapi.naver.com/v1/search/shop.xml?query=' + encodeURI(req.query.query); // xml 결과
var
request
=
require
(
'request'
);
console.log(req.query.query);
console.log(req.body.keyword);
var request = require('request');
var options = {
url: api_url,
headers: {'X-Naver-Client-Id':client_id, 'X-Naver-Client-Secret': client_secret}
...
...
@@ -22,4 +26,5 @@ app.get('/search/blog', function (req, res) {
});
app.listen(3000, function () {
console.log('http://127.0.0.1:3000/search/blog?query=검색어 app listening on port 3000!');
});
\ No newline at end of file
});
*/
\ No newline at end of file
...
...
views/main.ejs
View file @
176830d
...
...
@@ -9,6 +9,9 @@
<form
method=
"GET"
action=
"http://localhost:3000/rank"
>
<input
type=
"submit"
value=
"전체순위"
>
</form>
<form
method=
"POST"
action=
"http://localhost:3000/shop"
>
<input
type=
"text"
name=
"word"
placeholder=
"키워드"
>
<input
type=
"submit"
value=
"검색"
>
</form>
</body>
</html>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment