송민석

Success DB collection

config.js
node_modules/
\ No newline at end of file
DB_collect/config.js
DB_collect/node_modules/
\ No newline at end of file
......
const config = require('./config')
const mongoose = require("mongoose");
const { range } = require("express/lib/request");
const xlsx = require("xlsx");
const excelFile = xlsx.readFile("./GuideLine/인공지능학과 권장이수 가이드라인.xlsx");
const sheetName = excelFile.SheetNames[0];
const firstSheet = excelFile.Sheets[sheetName];
const jsonData = xlsx.utils.sheet_to_json(firstSheet);
var first_first = [];
var first_second = [];
var second_first = [];
var second_second = [];
var third_first = [];
var third_second = [];
var fourth_first = [];
var fourth_second = [];
var new_list = [];
function jason_to_arry() {
for (var data in jsonData) {
first_first.push(jsonData[data]['1학년 1학기']);
first_second.push(jsonData[data]['1학년 2학기']);
second_first.push(jsonData[data]['2학년 1학기']);
second_second.push(jsonData[data]['2학년 2학기']);
third_first.push(jsonData[data]['3학년 1학기']);
third_second.push(jsonData[data]['3학년 2학기']);
fourth_first.push(jsonData[data]['4학년 1학기']);
fourth_second.push(jsonData[data]['4학년 2학기']);
}
}
function remove_null() {
first_first = first_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
first_second = first_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
second_first = second_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
second_second = second_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
third_first = third_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
third_second = third_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
fourth_first = fourth_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
fourth_second = fourth_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
new_list.push(first_first);
new_list.push(first_second)
new_list.push(second_first)
new_list.push(second_second);
new_list.push(third_first)
new_list.push(third_second);
new_list.push(fourth_first);
new_list.push(fourth_second);
}
jason_to_arry()
remove_null()
const connect = mongoose.connect(config.url,
{
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log("DB : Succesfully Connected"))
.catch((err) => console.log(err.message));
var express = require('express');
const { Subinfo } = require('./models/model');
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A10628&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=aHGSkYnn7ZmXH5Wgx8So3tatw4J7LyR5g98tqYffSUU7qPhC7FFjOaemFCb8UgU5.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
formData: {
'attribute': 'lectListJson',
'lang': 'ko',
'loginYn': 'N',
'menu': '1',
'p_major': 'A07308',
'p_year': '2022',
'p_term': '10',
'initYn': 'Y'
}
};
request(options, async function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
const data = {}
for (var i in json["rows"]) {
// console.log(json["rows"][i])
}
var x = 0, y = 0;
for (var i = 0; i < new_list.length; i++) {
var z = '필수';
if (i % 2 == 0) {
x++;
}
for (var j = 0; j < new_list[i].length; j++) {
if (new_list[i][j] == '선택') {
z = '선택';
continue;
}
if (i % 2 == 0) {
y = 1;
} else {
y = 2;
}
var subinfo = new Subinfo({
campus: "국제",
college: "소프트웨어융합대학",
department: "인공지능학과",
grade: x + "학년" + y + "학기",
name: new_list[i][j],
choice: z,
})
subinfo.save((err, result) => {
if (err) {
return err;
} else {
// console.log(result);
}
})
}
}
for (var i in json["rows"]) {
var obj = {};
obj['time'] = json["rows"][i]["timetable"];
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
obj['name'] = json["rows"][i]["subjt_name"];
await Subinfo.findOne({department: "인공지능학과", name:obj['name']}).then((sub)=>{
if(sub){
var body={
prof:obj['prof'],
time:obj['time']
}
sub.credit=obj['credit']
sub.subject.push(body);
sub.save((err,result)=>{
if(err){
console.log(err)
}else if(result){
//console.log(result);
}
})
}
})
}
});
\ No newline at end of file
const config = require('./config')
const mongoose = require("mongoose");
const { range } = require("express/lib/request");
const xlsx = require("xlsx");
const excelFile = xlsx.readFile("./GuideLine/컴퓨터공학과 권장이수 가이드라인.xlsx");
const sheetName = excelFile.SheetNames[0];
const firstSheet = excelFile.Sheets[sheetName];
const jsonData = xlsx.utils.sheet_to_json(firstSheet);
var first_first = [];
var first_second = [];
var second_first = [];
var second_second = [];
var third_first = [];
var third_second = [];
var fourth_first = [];
var fourth_second = [];
var new_list = [];
function jason_to_arry() {
for (var data in jsonData) {
first_first.push(jsonData[data]['1학년 1학기']);
first_second.push(jsonData[data]['1학년 2학기']);
second_first.push(jsonData[data]['2학년 1학기']);
second_second.push(jsonData[data]['2학년 2학기']);
third_first.push(jsonData[data]['3학년 1학기']);
third_second.push(jsonData[data]['3학년 2학기']);
fourth_first.push(jsonData[data]['4학년 1학기']);
fourth_second.push(jsonData[data]['4학년 2학기']);
}
}
function remove_null() {
first_first = first_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
first_second = first_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
second_first = second_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
second_second = second_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
third_first = third_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
third_second = third_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
fourth_first = fourth_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
fourth_second = fourth_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
new_list.push(first_first);
new_list.push(first_second)
new_list.push(second_first)
new_list.push(second_second);
new_list.push(third_first)
new_list.push(third_second);
new_list.push(fourth_first);
new_list.push(fourth_second);
}
jason_to_arry()
remove_null()
const connect = mongoose.connect(config.url,
{
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log("DB : Succesfully Connected"))
.catch((err) => console.log(err.message));
var express = require('express');
const { Subinfo } = require('./models/model');
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A10627&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=aHGSkYnn7ZmXH5Wgx8So3tatw4J7LyR5g98tqYffSUU7qPhC7FFjOaemFCb8UgU5.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
formData: {
'attribute': 'lectListJson',
'lang': 'ko',
'loginYn': 'N',
'menu': '1',
'p_major': 'A07308',
'p_year': '2022',
'p_term': '10',
'initYn': 'Y'
}
};
request(options, async function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
const data = {}
for (var i in json["rows"]) {
// console.log(json["rows"][i])
}
var x = 0, y = 0;
for (var i = 0; i < new_list.length; i++) {
var z = '필수';
if (i % 2 == 0) {
x++;
}
for (var j = 0; j < new_list[i].length; j++) {
if (new_list[i][j] == '선택') {
z = '선택';
continue;
}
if (i % 2 == 0) {
y = 1;
} else {
y = 2;
}
var subinfo = new Subinfo({
campus: "국제",
college: "소프트웨어융합대학",
department: "컴퓨터공학과",
grade: x + "학년" + y + "학기",
name: new_list[i][j],
choice: z,
})
subinfo.save((err, result) => {
if (err) {
return err;
} else {
// console.log(result);
}
})
}
}
for (var i in json["rows"]) {
var obj = {};
obj['time'] = json["rows"][i]["timetable"];
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
obj['name'] = json["rows"][i]["subjt_name"];
await Subinfo.findOne({department: "컴퓨터공학과", name:obj['name']}).then((sub)=>{
if(sub){
var body={
prof:obj['prof'],
time:obj['time']
}
sub.credit=obj['credit']
sub.subject.push(body);
sub.save((err,result)=>{
if(err){
console.log(err)
}else if(result){
//console.log(result);
}
})
}
})
}
});
\ No newline at end of file
......@@ -2,7 +2,12 @@ const config = require('./config')
const mongoose = require("mongoose");
const { range } = require("express/lib/request");
const xlsx = require("xlsx");
const fs = require('fs')
const excelFile = xlsx.readFile("./GuideLine/소프트웨어융합학과_미래자동차.로봇 트랙 권장이수.xlsx");
const sheetName = excelFile.SheetNames[0];
const firstSheet = excelFile.Sheets[sheetName];
const jsonData = xlsx.utils.sheet_to_json(firstSheet);
var first_first = [];
var first_second = [];
var second_first = [];
......@@ -11,8 +16,8 @@ var third_first = [];
var third_second = [];
var fourth_first = [];
var fourth_second = [];
var new_list = {};
function jason_to_arry(jsonData) {
var new_list = [];
function jason_to_arry() {
for (var data in jsonData) {
first_first.push(jsonData[data]['1학년 1학기']);
first_second.push(jsonData[data]['1학년 2학기']);
......@@ -24,9 +29,8 @@ function jason_to_arry(jsonData) {
fourth_second.push(jsonData[data]['4학년 2학기']);
}
}
// json -> array로 변경
function remove_null(major) {
// jason -> array로 변경
function remove_null() {
first_first = first_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
......@@ -51,40 +55,17 @@ function remove_null(major) {
fourth_second = fourth_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
new_list[major]=[first_first,first_second,second_first,second_second,third_first,third_second,fourth_first,fourth_second]
// new_list.push(first_first);
// new_list.push(first_second)
// new_list.push(second_first)
// new_list.push(second_second);
// new_list.push(third_first)
// new_list.push(third_second);
// new_list.push(fourth_first);
// new_list.push(fourth_second);
new_list.push(first_first);
new_list.push(first_second)
new_list.push(second_first)
new_list.push(second_second);
new_list.push(third_first)
new_list.push(third_second);
new_list.push(fourth_first);
new_list.push(fourth_second);
}
fs.readdirSync("./GuideLine").forEach(file => {
// console.log(file);
var major=file.split(' ')[0]
console.log(major)
const excelFile = xlsx.readFile(`./GuideLine/${file}`)
const sheetName = excelFile.SheetNames[0];
const firstSheet = excelFile.Sheets[sheetName];
const jsonData = xlsx.utils.sheet_to_json(firstSheet)
jason_to_arry(jsonData)
remove_null(major)
first_first = [];
first_second = [];
second_first = [];
second_second = [];
third_first = [];
third_second = [];
fourth_first = [];
fourth_second = [];
});
console.log(new_list[''])
// const excelFile = xlsx.readFile("./GuideLine/컴퓨터공학과 권장이수 가이드라인.xlsx");
// null 값 제거
jason_to_arry()
remove_null()
const connect = mongoose.connect(config.url,
......@@ -98,13 +79,11 @@ const connect = mongoose.connect(config.url,
var express = require('express');
var major_list = ["A07337", "A10628", "A07308", "A10627"];
const { Subinfo } = require('./models/model');
var request = require('request');
for (i in major_list) {
var options = {
var options = {
'method': 'GET',
'url': `https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=${i}&p_year=2022&p_term=10&initYn=Y`,
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A07337&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=aHGSkYnn7ZmXH5Wgx8So3tatw4J7LyR5g98tqYffSUU7qPhC7FFjOaemFCb8UgU5.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
......@@ -118,18 +97,21 @@ for (i in major_list) {
'p_term': '10',
'initYn': 'Y'
}
};
request(options, async function (error, response) {
};
request(options, async function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
const data = {}
for (var i in json["rows"]) {
// console.log(json["rows"][i])
}
var x = 0, y = 0;
var z = '필수';
for (var i = 0; i < new_list.length; i++) {
var z = '필수';
if (i % 2 == 0) {
x++;
}
......@@ -146,10 +128,10 @@ for (i in major_list) {
var subinfo = new Subinfo({
campus: "국제",
college: "소프트웨어융합대학",
department: "컴퓨터공학과",
department: "소프트웨어융합학과_미래자동차.로봇",
grade: x + "학년" + y + "학기",
name: new_list[i][j],
choice: z
choice: z,
})
subinfo.save((err, result) => {
if (err) {
......@@ -166,23 +148,22 @@ for (i in major_list) {
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
obj['name'] = json["rows"][i]["subjt_name"];
await Subinfo.findOne({ name: obj['name'] }).then((sub) => {
if (sub) {
var body = {
prof: obj['prof'],
time: obj['time']
await Subinfo.findOne({department: "소프트웨어융합학과_미래자동차.로봇", name:obj['name']}).then((sub)=>{
if(sub){
var body={
prof:obj['prof'],
time:obj['time']
}
sub.credit = obj['credit']
sub.credit=obj['credit']
sub.subject.push(body);
sub.save((err, result) => {
if (err) {
sub.save((err,result)=>{
if(err){
console.log(err)
} else if (result) {
console.log(result);
}else if(result){
//console.log(result);
}
})
}
})
}
});
};
\ No newline at end of file
});
\ No newline at end of file
......
const config = require('./config')
const mongoose = require("mongoose");
const { range } = require("express/lib/request");
const xlsx = require("xlsx");
const excelFile = xlsx.readFile("./GuideLine/소프트웨어융합학과_데이터사이언스 트랙.xlsx");
const sheetName = excelFile.SheetNames[0];
const firstSheet = excelFile.Sheets[sheetName];
const jsonData = xlsx.utils.sheet_to_json(firstSheet);
var first_first = [];
var first_second = [];
var second_first = [];
var second_second = [];
var third_first = [];
var third_second = [];
var fourth_first = [];
var fourth_second = [];
var new_list = [];
function jason_to_arry() {
for (var data in jsonData) {
first_first.push(jsonData[data]['1학년 1학기']);
first_second.push(jsonData[data]['1학년 2학기']);
second_first.push(jsonData[data]['2학년 1학기']);
second_second.push(jsonData[data]['2학년 2학기']);
third_first.push(jsonData[data]['3학년 1학기']);
third_second.push(jsonData[data]['3학년 2학기']);
fourth_first.push(jsonData[data]['4학년 1학기']);
fourth_second.push(jsonData[data]['4학년 2학기']);
}
}
// jason -> array로 변경
function remove_null() {
first_first = first_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
first_second = first_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
second_first = second_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
second_second = second_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
third_first = third_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
third_second = third_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
fourth_first = fourth_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
fourth_second = fourth_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
new_list.push(first_first);
new_list.push(first_second)
new_list.push(second_first)
new_list.push(second_second);
new_list.push(third_first)
new_list.push(third_second);
new_list.push(fourth_first);
new_list.push(fourth_second);
}
jason_to_arry()
remove_null()
const connect = mongoose.connect(config.url,
{
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log("DB : Succesfully Connected"))
.catch((err) => console.log(err.message));
var express = require('express');
const { Subinfo } = require('./models/model');
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A07337&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=aHGSkYnn7ZmXH5Wgx8So3tatw4J7LyR5g98tqYffSUU7qPhC7FFjOaemFCb8UgU5.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
formData: {
'attribute': 'lectListJson',
'lang': 'ko',
'loginYn': 'N',
'menu': '1',
'p_major': 'A07308',
'p_year': '2022',
'p_term': '10',
'initYn': 'Y'
}
};
request(options, async function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
const data = {}
for (var i in json["rows"]) {
// console.log(json["rows"][i])
}
var x = 0, y = 0;
for (var i = 0; i < new_list.length; i++) {
var z = '필수';
if (i % 2 == 0) {
x++;
}
for (var j = 0; j < new_list[i].length; j++) {
if (new_list[i][j] == '선택') {
z = '선택';
continue;
}
if (i % 2 == 0) {
y = 1;
} else {
y = 2;
}
var subinfo = new Subinfo({
campus: "국제",
college: "소프트웨어융합대학",
department: "소프트웨어융합학과_데이터사이언스",
grade: x + "학년" + y + "학기",
name: new_list[i][j],
choice: z,
})
subinfo.save((err, result) => {
if (err) {
return err;
} else {
// console.log(result);
}
})
}
}
for (var i in json["rows"]) {
var obj = {};
obj['time'] = json["rows"][i]["timetable"];
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
obj['name'] = json["rows"][i]["subjt_name"];
await Subinfo.findOne({department: "소프트웨어융합학과_데이터사이언스", name:obj['name']}).then((sub)=>{
if(sub){
var body={
prof:obj['prof'],
time:obj['time']
}
sub.credit=obj['credit']
sub.subject.push(body);
sub.save((err,result)=>{
if(err){
console.log(err)
}else if(result){
//console.log(result);
}
})
}
})
}
});
\ No newline at end of file
const config = require('./config')
const mongoose = require("mongoose");
const { range } = require("express/lib/request");
const xlsx = require("xlsx");
const excelFile = xlsx.readFile("./GuideLine/소프트웨어융합학과_게임콘텐츠 트랙.xlsx");
const sheetName = excelFile.SheetNames[0];
const firstSheet = excelFile.Sheets[sheetName];
const jsonData = xlsx.utils.sheet_to_json(firstSheet);
var first_first = [];
var first_second = [];
var second_first = [];
var second_second = [];
var third_first = [];
var third_second = [];
var fourth_first = [];
var fourth_second = [];
var new_list = [];
function jason_to_arry() {
for (var data in jsonData) {
first_first.push(jsonData[data]['1학년 1학기']);
first_second.push(jsonData[data]['1학년 2학기']);
second_first.push(jsonData[data]['2학년 1학기']);
second_second.push(jsonData[data]['2학년 2학기']);
third_first.push(jsonData[data]['3학년 1학기']);
third_second.push(jsonData[data]['3학년 2학기']);
fourth_first.push(jsonData[data]['4학년 1학기']);
fourth_second.push(jsonData[data]['4학년 2학기']);
}
}
function remove_null() {
first_first = first_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
first_second = first_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
second_first = second_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
second_second = second_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
third_first = third_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
third_second = third_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
fourth_first = fourth_first.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
fourth_second = fourth_second.filter(function (item) {
return item !== null && item !== undefined && item !== '';
});
new_list.push(first_first);
new_list.push(first_second)
new_list.push(second_first)
new_list.push(second_second);
new_list.push(third_first)
new_list.push(third_second);
new_list.push(fourth_first);
new_list.push(fourth_second);
}
jason_to_arry()
remove_null()
const connect = mongoose.connect(config.url,
{
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log("DB : Succesfully Connected"))
.catch((err) => console.log(err.message));
var express = require('express');
const { Subinfo } = require('./models/model');
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A07337&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=aHGSkYnn7ZmXH5Wgx8So3tatw4J7LyR5g98tqYffSUU7qPhC7FFjOaemFCb8UgU5.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
formData: {
'attribute': 'lectListJson',
'lang': 'ko',
'loginYn': 'N',
'menu': '1',
'p_major': 'A07308',
'p_year': '2022',
'p_term': '10',
'initYn': 'Y'
}
};
request(options, async function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
const data = {}
for (var i in json["rows"]) {
// console.log(json["rows"][i])
}
var x = 0, y = 0;
for (var i = 0; i < new_list.length; i++) {
var z = '필수';
if (i % 2 == 0) {
x++;
}
for (var j = 0; j < new_list[i].length; j++) {
if (new_list[i][j] == '선택') {
z = '선택';
continue;
}
if (i % 2 == 0) {
y = 1;
} else {
y = 2;
}
var subinfo = new Subinfo({
campus: "국제",
college: "소프트웨어융합대학",
department: "소프트웨어융합학과_게임콘텐츠",
grade: x + "학년" + y + "학기",
name: new_list[i][j],
choice: z,
})
subinfo.save((err, result) => {
if (err) {
return err;
} else {
// console.log(result);
}
})
}
}
for (var i in json["rows"]) {
var obj = {};
obj['time'] = json["rows"][i]["timetable"];
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
obj['name'] = json["rows"][i]["subjt_name"];
await Subinfo.findOne({department: "소프트웨어융합학과_게임콘텐츠", name:obj['name']}).then((sub)=>{
if(sub){
var body={
prof:obj['prof'],
time:obj['time']
}
sub.credit=obj['credit']
sub.subject.push(body);
sub.save((err,result)=>{
if(err){
console.log(err)
}else if(result){
// console.log(result);
}
})
}
})
}
});
\ No newline at end of file
......@@ -17,4 +17,4 @@ const mongoose = require("mongoose");
});
const Subinfo = mongoose.model('Subinfo', SubSchema);
module.exports = {Subinfo};
\ No newline at end of file
module.exports = { Subinfo };
\ No newline at end of file
......
This diff is collapsed. Click to expand it.
{
"name": "db_collect",
"version": "1.0.0",
"description": "",
"main": "AI.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.1",
"mongoose": "^6.3.5",
"request": "^2.88.2",
"xlsx": "^0.18.5"
}
......
const xlsx = require( "xlsx" );
// 엑셀 파일을 가져오기
const excelFile = xlsx.readFile("./GuideLine/컴퓨터공학과 권장이수 가이드라인.xlsx");
// 엑셀 파일의 첫번째 시트의 정보 추출
const sheetName = excelFile.SheetNames[0];
const firstSheet = excelFile.Sheets[sheetName];
const jsonData = xlsx.utils.sheet_to_json(firstSheet);
var first_first = [];
var first_second = [];
var second_first = [];
var second_second = [];
var third_first = [];
var third_second = [];
var fourth_first = [];
var fourth_second = [];
function jason_to_arry() {
for (var data in jsonData){
first_first.push(jsonData[data]['1학년 1학기']);
first_second.push(jsonData[data]['1학년 2학기']);
second_first.push(jsonData[data]['2학년 1학기']);
second_second.push(jsonData[data]['2학년 2학기']);
third_first.push(jsonData[data]['3학년 1학기']);
third_second.push(jsonData[data]['3학년 2학기']);
fourth_first.push(jsonData[data]['4학년 1학기']);
fourth_second.push(jsonData[data]['4학년 2학기']);
}
}
// jason -> array로 변경
function remove_null() {
first_first = first_first.filter(function(item) {
return item !== null && item !== undefined && item !== '';
});
first_second = first_second.filter(function(item) {
return item !== null && item !== undefined && item !== '';
});
second_first = second_first.filter(function(item) {
return item !== null && item !== undefined && item !== '';
});
second_second = second_second.filter(function(item) {
return item !== null && item !== undefined && item !== '';
});
third_first = third_first.filter(function(item) {
return item !== null && item !== undefined && item !== '';
});
third_second = third_second.filter(function(item) {
return item !== null && item !== undefined && item !== '';
});
fourth_first = fourth_first.filter(function(item) {
return item !== null && item !== undefined && item !== '';
});
fourth_second = fourth_second.filter(function(item) {
return item !== null && item !== undefined && item !== '';
});
}
// null 값 제거
jason_to_arry()
remove_null()
console.log(first_first);
This diff is collapsed. Click to expand it.
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A07337&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=aHGSkYnn7ZmXH5Wgx8So3tatw4J7LyR5g98tqYffSUU7qPhC7FFjOaemFCb8UgU5.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
formData: {
'attribute': 'lectListJson',
'lang': 'ko',
'loginYn': 'N',
'menu': '1',
'p_major': 'A07337',
'p_year': '2022',
'p_term': '10',
'initYn': 'Y'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
const data = {}
for (var i in json["rows"]){
var obj = {};
obj['name'] = json["rows"][i]["subjt_name"];
obj['time'] = json["rows"][i]["timetable"];
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
console.log(obj);
}
});
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A10628&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=0hka3HzdSAOOvWw17F0W3OixVWW5MKzJg31nZrYU3yjMlmIv7GF9vasjvDsYwTAe.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
formData: {
'attribute': 'lectListJson',
'lang': 'ko',
'loginYn': 'N',
'menu': '1',
'p_major': 'A10628',
'p_year': '2022',
'p_term': '10',
'initYn': 'Y'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
const data = {}
for (var i in json["rows"]){
var obj = {};
obj['name'] = json["rows"][i]["subjt_name"];
obj['time'] = json["rows"][i]["timetable"];
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
console.log(obj);
}
});
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A07308&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=aHGSkYnn7ZmXH5Wgx8So3tatw4J7LyR5g98tqYffSUU7qPhC7FFjOaemFCb8UgU5.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
formData: {
'attribute': 'lectListJson',
'lang': 'ko',
'loginYn': 'N',
'menu': '1',
'p_major': 'A07308',
'p_year': '2022',
'p_term': '10',
'initYn': 'Y'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
const data = {}
for (var i in json["rows"]){
var obj = {};
obj['name'] = json["rows"][i]["subjt_name"];
obj['time'] = json["rows"][i]["timetable"];
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
console.log(obj);
}
});
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://sugang.khu.ac.kr/core?attribute=lectListJson&lang=ko&loginYn=N&menu=1&p_major=A10627&p_year=2022&p_term=10&initYn=Y',
'headers': {
'Cookie': 'JSESSIONID=0hka3HzdSAOOvWw17F0W3OixVWW5MKzJg31nZrYU3yjMlmIv7GF9vasjvDsYwTAe.amV1c19kb21haW4vV0hfU3VnYW5nMQ==; WMONID=R84FN19dbP4'
},
formData: {
'attribute': 'lectListJson',
'lang': 'ko',
'loginYn': 'N',
'menu': '1',
'p_major': 'A10627',
'p_year': '2022',
'p_term': '10',
'initYn': 'Y'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
var jason = response.body
var json = JSON.parse(jason)
for (var i in json["rows"]){
var obj = {};
obj['name'] = json["rows"][i]["subjt_name"];
obj['time'] = json["rows"][i]["timetable"];
obj['prof'] = json["rows"][i]["teach_na"];
obj['credit'] = json["rows"][i]["unit_num"];
console.log(obj);
}
});
\ No newline at end of file