전세계

테스트: axios와 cheerio로 롤인벤 크롤링 테스트

......@@ -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');
});
......
......@@ -13,6 +13,8 @@
"author": "Jeon segye",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2",
"cheerio": "^1.0.0-rc.3",
"express": "^4.17.1"
}
}
......