main.js 1.18 KB
const mysql = require("mysql");
const khuuniv = require('./site_modules/KHU')
const swuniv = require('./site_modules/swuniv')
const janghak1 = require("./site_modules/janghak1")
const janghak2 = require("./site_modules/janghak2")

async function loading(){
    li = await swuniv.loading();
    for(var i = 0; i < li.length;i++){
        await insertNotice(li[i]);
    }
    li = await khuuniv.loading();
    for(var i = 0; i < li.length;i++){
        await insertNotice(li[i]);
    }
    li = await janghak1.loading();
    for(var i = 0; i < li.length;i++){
        await insertNotice(li[i]);
    }
    li = await janghak2.loading();
    for(var i = 0; i < li.length;i++){
        await insertNotice(li[i]);
    }
}

var connection = mysql.createConnection({
    host: "34.64.183.182",
    user: 'root',
    password: '',
    database: 'KhuNotice'
})

connection.connect();

async function insertNotice(singleNotice){
    date = singleNotice.date;
    title = singleNotice.title;
    link = singleNotice.link;
    site = singleNotice.site;
    
    await connection.query(`insert into noticeList (date, title, link, site) values('${date}','${title}','${link}','${site}')`,function(err){});

}


loading();