swuniv.js
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const axios = require("axios");
const cheerio = require("cheerio");
var getHTML = async function(link){
try{
return await axios.get(link);
} catch(e){
console.log(e);
}
}
getHTML("http://software.khu.ac.kr/board5/bbs/board.php?bo_table=05_01&page=1").then(function(HTML){
var $ = cheerio.load(HTML.data);
var titleList = $('tr');
var list = [];
titleList.each(function(i, elem){
list[i] = {
title: $(this).find(".bo_tit").text().replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/(^\s*)|(\s*$)/gi, ""),
link: $(this).find("a").attr('href').replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/(^\s*)|(\s*$)/gi, ""),
date: $(this).find(".td_datetime").text().replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/(^\s*)|(\s*$)/gi, ""),
site: '소프트웨어 융합대학 공지사항'
}
})
});
getHTML("http://software.khu.ac.kr/board5/bbs/board.php?bo_table=05_01&page=2").then(function(HTML){
var $ = cheerio.load(HTML.data);
var titleList = $('tr');
var list = [];
titleList.each(function(i, elem){
list[i] = {
title: $(this).find(".bo_tit").text().replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/(^\s*)|(\s*$)/gi, ""),
link: $(this).find("a").attr('href').replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/(^\s*)|(\s*$)/gi, ""),
date: $(this).find(".td_datetime").text().replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/(^\s*)|(\s*$)/gi, ""),
site: '소프트웨어 융합대학 공지사항'
}
})
});
for(var i =0;i<list.length;i++){
console.log(i);
console.log(list[i]);
}