swuniv.js
1.05 KB
const axios = require("axios");
const cheerio = require("cheerio");
var getHTML = async function(link){
try{
return await axios.get(link);
} catch(e){
console.log(e);
}
}
async function getList(link){
list = [];
HTML = await getHTML(link);
var $ = cheerio.load(HTML.data);
var titleList = $('tr');
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: '소프트웨어 융합대학 공지사항'
}
})
list = list.filter(item => item.title);
return list
}
async function loading(){
li = await getList('http://software.khu.ac.kr/board5/bbs/board.php?bo_table=05_01&page=1');
console.log(li);
}
module.exports.loading = loading;