Skip to content

Commit 0b4e359

Browse files
committed
html parsing
1 parent a72dd90 commit 0b4e359

File tree

3 files changed

+195
-1
lines changed

3 files changed

+195
-1
lines changed

excel/excelParser.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const xlsx = require('xlsx');
2+
const axios = require('axios');
3+
const cheerio = require('cheerio');
24

35
const workbook = xlsx.readFile('./data.xlsx');
46

@@ -8,4 +10,17 @@ const records = xlsx.utils.sheet_to_json(ws);
810

911
for(const [i, r] of records.entries()) {
1012
console.log(i, r.제목, r.링크);
11-
}
13+
}
14+
15+
const crawler = async () => {
16+
await Promise.all(records.map( async (r) => {
17+
const response = await axios.get(r.링크);
18+
if (response.status === 200) {
19+
const html = response.data;
20+
const $ = cheerio.load(html);
21+
const text = $('.score.score_left .star_score').text();
22+
console.log(r.제목, '평점', text.trim());
23+
}
24+
}));
25+
};
26+
crawler();

package-lock.json

+177
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12+
"axios": "^0.18.0",
13+
"cheerio": "^1.0.0-rc.3",
1214
"csv-parse": "^4.4.1",
1315
"xlsx": "^0.14.3"
1416
}

0 commit comments

Comments
 (0)