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.69.247.0",
    user: 'root',
    password: 'kcss3711',
    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();