Toggle navigation
Toggle navigation
This project
Loading...
Sign in
전세계
/
FakerQuiz
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-05-31 18:42:07 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
32fc2d2a8ba5e510039bf53c9c98c2ce87e25304
32fc2d2a
1 parent
42f35b5e
테스트: axios와 cheerio로 롤인벤 크롤링 테스트
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
app.js
package.json
app.js
View file @
32fc2d2
...
...
@@ -2,6 +2,26 @@ const express = require('express');
const
app
=
express
();
const
port
=
80
;
const
axios
=
require
(
'axios'
);
const
cheerio
=
require
(
'cheerio'
);
const
getHTML
=
async
()
=>
{
try
{
return
await
axios
.
get
(
'http://lol.inven.co.kr/dataninfo/proteam/progamer.php?code=135'
);
}
catch
(
error
)
{
console
.
error
(
error
);
}
};
getHTML
()
.
then
(
html
=>
{
const
$
=
cheerio
.
load
(
html
.
data
);
var
title
=
$
(
"h2.block.name"
).
text
();
return
title
;
})
.
then
(
res
=>
console
.
log
(
res
));
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
res
.
send
(
'Express Test'
);
});
...
...
package.json
View file @
32fc2d2
...
...
@@ -13,6 +13,8 @@
"author"
:
"Jeon segye"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"axios"
:
"^0.19.2"
,
"cheerio"
:
"^1.0.0-rc.3"
,
"express"
:
"^4.17.1"
}
}
...
...
Please
register
or
login
to post a comment