전세계

기능: LCK 통산 전적 크롤링

Showing 1 changed file with 20 additions and 3 deletions
...@@ -4,10 +4,13 @@ const port = 80; ...@@ -4,10 +4,13 @@ const port = 80;
4 4
5 const axios = require('axios'); 5 const axios = require('axios');
6 const cheerio = require('cheerio'); 6 const cheerio = require('cheerio');
7 +const url = 'http://lol.inven.co.kr/dataninfo/proteam/progamer.php?code=135';
8 +
9 +var fakerData = {};
7 10
8 const getHTML = async () => { 11 const getHTML = async () => {
9 try { 12 try {
10 - return await axios.get('http://lol.inven.co.kr/dataninfo/proteam/progamer.php?code=135'); 13 + return await axios.get(url);
11 } catch (error) { 14 } catch (error) {
12 console.error(error); 15 console.error(error);
13 } 16 }
...@@ -16,9 +19,23 @@ const getHTML = async () => { ...@@ -16,9 +19,23 @@ const getHTML = async () => {
16 getHTML() 19 getHTML()
17 .then(html => { 20 .then(html => {
18 const $ = cheerio.load(html.data); 21 const $ = cheerio.load(html.data);
19 - var title = $("h2.block.name").text();
20 22
21 - return title; 23 + // LCK 통산 전적
24 + var tr = $('table.table.log_list.log01 tbody').children();
25 + var td = tr.eq(0).children();
26 + fakerData['lCK'] = {
27 + totalGamePlay : td.eq(1).text(),
28 + totalWin : td.eq(2).text(),
29 + totalLose : td.eq(3).text(),
30 + winRate : td.eq(4).text(),
31 + killPerMatch : td.eq(5).text(),
32 + deathPerMatch : td.eq(6).text(),
33 + assistPerMatch : td.eq(7).text(),
34 + kDA : td.eq(8).text(),
35 + killParticipation : td.eq(9).text()
36 + };
37 +
38 + return fakerData;
22 }) 39 })
23 .then(res => console.log(res)); 40 .then(res => console.log(res));
24 41
......