Showing
2 changed files
with
22 additions
and
0 deletions
... | @@ -2,6 +2,26 @@ const express = require('express'); | ... | @@ -2,6 +2,26 @@ const express = require('express'); |
2 | const app = express(); | 2 | const app = express(); |
3 | const port = 80; | 3 | const port = 80; |
4 | 4 | ||
5 | +const axios = require('axios'); | ||
6 | +const cheerio = require('cheerio'); | ||
7 | + | ||
8 | +const getHTML = async () => { | ||
9 | + try { | ||
10 | + return await axios.get('http://lol.inven.co.kr/dataninfo/proteam/progamer.php?code=135'); | ||
11 | + } catch (error) { | ||
12 | + console.error(error); | ||
13 | + } | ||
14 | +}; | ||
15 | + | ||
16 | +getHTML() | ||
17 | + .then(html => { | ||
18 | + const $ = cheerio.load(html.data); | ||
19 | + var title = $("h2.block.name").text(); | ||
20 | + | ||
21 | + return title; | ||
22 | + }) | ||
23 | + .then(res => console.log(res)); | ||
24 | + | ||
5 | app.get('/', (req, res) => { | 25 | app.get('/', (req, res) => { |
6 | res.send('Express Test'); | 26 | res.send('Express Test'); |
7 | }); | 27 | }); | ... | ... |
... | @@ -13,6 +13,8 @@ | ... | @@ -13,6 +13,8 @@ |
13 | "author": "Jeon segye", | 13 | "author": "Jeon segye", |
14 | "license": "ISC", | 14 | "license": "ISC", |
15 | "dependencies": { | 15 | "dependencies": { |
16 | + "axios": "^0.19.2", | ||
17 | + "cheerio": "^1.0.0-rc.3", | ||
16 | "express": "^4.17.1" | 18 | "express": "^4.17.1" |
17 | } | 19 | } |
18 | } | 20 | } | ... | ... |
-
Please register or login to post a comment