최재은

Add ce.khu.ac.kr crawling & lecture data file

{"_id":{"$oid":"5cf0da0c7c7624ccbced2825"},"lecturename":"전공 기초","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2826"},"lecturename":"미분적분학","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2827"},"lecturename":"선형대수","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2828"},"lecturename":"확률 및 랜덤변수","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2829"},"lecturename":"미분방정식","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282a"},"lecturename":"이산구조","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282b"},"lecturename":"전공 필수","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282c"},"lecturename":"웹/파이선프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282d"},"lecturename":"객체지향프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282e"},"lecturename":"논리회로","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282f"},"lecturename":"컴퓨터구조","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2830"},"lecturename":"자료구조","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2831"},"lecturename":"운영체제","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2832"},"lecturename":"컴퓨터네트워크","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2833"},"lecturename":"소프트웨어공학","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2834"},"lecturename":"알고리즘분석","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2835"},"lecturename":"데이터베이스","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2836"},"lecturename":"오픈소스SW개발","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2837"},"lecturename":"IT기술영어 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2838"},"lecturename":"IT기술영어 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2839"},"lecturename":"IT기술영어 3","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283a"},"lecturename":"캡스톤디자인 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283b"},"lecturename":"캡스톤디자인 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283c"},"lecturename":"졸업논문","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283d"},"lecturename":"전공 선택","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283e"},"lecturename":"문제해결","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283f"},"lecturename":"형식언어 및컴파일러","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2840"},"lecturename":"파일처리","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2841"},"lecturename":"멀티미디어시스템","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2842"},"lecturename":"시스템분석 및 설계","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2843"},"lecturename":"프로그래밍언어구조론","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2844"},"lecturename":"JAVA프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2845"},"lecturename":"SW스타트업비즈니스","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2846"},"lecturename":"SW스타트업프로젝트","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2847"},"lecturename":"최신기술프로젝트 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2848"},"lecturename":"최신기술프로젝트 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2849"},"lecturename":"최신기술콜로키움 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284a"},"lecturename":"최신기술콜로키움 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284b"},"lecturename":"단기현장실습","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284c"},"lecturename":"장기현장실습","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284d"},"lecturename":"연구연수활동 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284e"},"lecturename":"연구연수활동 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284f"},"lecturename":"독립심화학습1 (컴퓨터공학과)","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2850"},"lecturename":"독립심화학습2 (컴퓨터공학과)","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2851"},"lecturename":"인공지능","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2852"},"lecturename":"머신러닝","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2853"},"lecturename":"빅데이터프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2854"},"lecturename":"클라우드컴퓨팅","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2855"},"lecturename":"데이터센터프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2856"},"lecturename":"네트워크분석및 설계","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2857"},"lecturename":"인터넷프로토콜및 프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2858"},"lecturename":"정보보호","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2859"},"lecturename":"모바일프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285a"},"lecturename":"웹서비스프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285b"},"lecturename":"리눅스시스템프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285c"},"lecturename":"IoT디지털시스템","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285d"},"lecturename":"IoT소프트웨어","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285e"},"lecturename":"로봇소프트웨어","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285f"},"lecturename":"영상처리","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2860"},"lecturename":"컴퓨터그래픽스","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2861"},"lecturename":"멀티미디어처리","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2862"},"lecturename":"인간-컴퓨터상호작용","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2863"},"lecturename":"UI/UX프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2864"},"lecturename":"컴퓨터비젼","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2865"},"lecturename":"디자인적사고","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2866"},"lecturename":"신호와시스템","__v":{"$numberInt":"0"}}
const puppeteer = require('puppeteer');
const request = require('request');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://ce.khu.ac.kr/index.php?hCode=UNIVERSITY_02_01_01');
await page.screenshot({path: 'test.png'});
var lecture = [];
lecture = await page.evaluate(() => {
const anchors = Array.from(document.querySelectorAll('#conTD > td > div > table > tbody > tr > td:nth-child(2)'));
return anchors.map(anchor => anchor.textContent);
})
lecture.push("디자인적사고")
lecture.push("신호와시스템")
console.log(lecture)
var opts
var posturl = "mongodb://localhost/facebookbot" + "/lectures"
for(var i=0; i<lecture.length; i++){
console.log(lecture[i])
request.post('http://127.0.0.1:4500/lectures', {
form: {
lecturename: lecture[i]
}
})
}
await browser.close();
})();
\ No newline at end of file
const mongoose = require('mongoose');
// Define Schemes
const lectureSchema = new mongoose.Schema({
lectureid: { type: String, unique: true },
lecturename: { type: String},
proname: { type: String },
avg_rate: { type: Number }
});
const reviewSchema = new mongoose.Schema({
lectureid: { type: String, required: true, unique: true },
review: { type: String, required: true }
const LectureSchema = new mongoose.Schema({
lecturename: { type: String, required: true, unique: true }
});
// // Create new lecture document
lectureSchema.statics.create = function (payload) {
// // Create new review document
LectureSchema.statics.create = function (payload) {
// this === Model
const lecture = new this(payload);
const review = new this(payload);
// return Promise
return lecture.save();
return review.save();
};
// Find All
lectureSchema.statics.findAll = function () {
LectureSchema.statics.findAll = function () {
// return promise
// V4부터 exec() 필요없음
return this.find({});
};
// Find One by lectureid
lectureSchema.statics.findOneBylectureid = function (lectureid) {
return this.findOne({ lectureid });
// Find One by lecturename
LectureSchema.statics.findOneBylecturename = function (lecturename) {
return this.findOne({ lecturename });
};
// Update by lectureid
lectureSchema.statics.updateBylectureid = function (lectureid, payload) {
// Update by lecturename
LectureSchema.statics.updateBylecturename = function (lecturename, payload) {
// { new: true }: return the modified document rather than the original. defaults to false
return this.findOneAndUpdate({ lectureid }, payload, { new: true });
return this.findOneAndUpdate({ lecturename }, payload, { new: true });
};
// Delete by lectureid
lectureSchema.statics.deleteBylectureid = function (lectureid) {
return this.remove({ lectureid });
// Delete by lecturename
LectureSchema.statics.deleteBylecturename = function (lecturename) {
return this.remove({ lecturename });
};
// Create Model & Export
module.exports = mongoose.model('Lecture', lectureSchema);
module.exports = mongoose.model('Lecture', LectureSchema);
\ No newline at end of file
......
const mongoose = require('mongoose');
// Define Schemes
const reviewSchema = new mongoose.Schema({
lectureid: { type: String, required: true, unique: true },
review: { type: String, required: true }
lecturename: { type: String },
proname: { type: String },
avg_rate: { type: Number },
review: {type : String}
});
// // Create new review document
// // Create new lecture document
reviewSchema.statics.create = function (payload) {
// this === Model
const review = new this(payload);
const lecture = new this(payload);
// return Promise
return review.save();
return lecture.save();
};
// Find All
reviewSchema.statics.findAll = function () {
// Find lecturename
reviewSchema.statics.findBylecturename = function (lecturename) {
// return promise
// V4부터 exec() 필요없음
return this.find({});
return this.find({ lecturename });
};
// Find One by reviewid
reviewSchema.statics.findOneByreviewid = function (reviewid) {
return this.findOne({ reviewid });
// Find by professor name
reviewSchema.statics.findByproname = function (proname) {
return this.find({ proname });
};
// Update by reviewid
reviewSchema.statics.updateByreviewid = function (reviewid, payload) {
// Update by lecturename
reviewSchema.statics.updateBylecturename = function (lecturename, payload) {
// { new: true }: return the modified document rather than the original. defaults to false
return this.findOneAndUpdate({ reviewid }, payload, { new: true });
return this.findOneAndUpdate({ lecturename }, payload, { new: true });
};
// Delete by reviewid
reviewSchema.statics.deleteByreviewid = function (reviewid) {
return this.remove({ reviewid });
// Delete by lecturename
reviewSchema.statics.deleteBylecturename = function (lecturename) {
return this.remove({ lecturename });
};
// Create Model & Export
......
......@@ -617,12 +617,25 @@
}
},
"mongodb": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.5.tgz",
"integrity": "sha512-VEu2nsfFMwWA6q6JVnlJ2kNVwjluU4op2J/YiG1LeI14t9HotLXbg8w3I794BvezC4ZCZ/wBTTdby01txalwwQ==",
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.6.tgz",
"integrity": "sha512-qnHc4tjEkHKemuzBq9R7ycYnhFE0Dlpt6+n6suoZp2DcDdqviQ+teloJU24fsOw/PLmr75yGk4mRx/YabjDQEQ==",
"requires": {
"mongodb-core": "3.2.5",
"mongodb-core": "3.2.6",
"safe-buffer": "^5.1.2"
},
"dependencies": {
"mongodb-core": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.6.tgz",
"integrity": "sha512-i+XRVjur9D0ywGF7cFebOUnALnbvMHajdNhhl3TQuopW6QDE655G8CpPeERbqSqfa3rOKEUo08lENDIiBIuAvQ==",
"requires": {
"bson": "^1.1.1",
"require_optional": "^1.0.1",
"safe-buffer": "^5.1.2",
"saslprep": "^1.0.0"
}
}
}
},
"mongodb-core": {
......@@ -656,6 +669,15 @@
"sliced": "1.0.1"
},
"dependencies": {
"mongodb": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.5.tgz",
"integrity": "sha512-VEu2nsfFMwWA6q6JVnlJ2kNVwjluU4op2J/YiG1LeI14t9HotLXbg8w3I794BvezC4ZCZ/wBTTdby01txalwwQ==",
"requires": {
"mongodb-core": "3.2.5",
"safe-buffer": "^5.1.2"
}
},
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
......
......@@ -13,6 +13,7 @@
"body-parser": "^1.19.0",
"dotenv": "^8.0.0",
"express": "^4.17.0",
"mongodb": "^3.2.6",
"mongoose": "^5.5.11",
"puppeteer": "^1.17.0",
"puppeteer-core": "^1.17.0",
......
......@@ -4,41 +4,41 @@ const Lecture = require('../models/lecture');
// Find All
router.get('/', (req, res) => {
Lecture.findAll()
.then((lectures) => {
if (!lectures.length) return res.status(404).send({ err: 'Lecture not found' });
res.send(`find successfully: ${lectures}`);
.then((Lectures) => {
if (!Lectures.length) return res.status(404).send({ err: 'Lecture not found' });
res.send(`find successfully: ${Lectures}`);
})
.catch(err => res.status(500).send(err));
});
// Find One by lectureid
router.get('/lectureid/:lectureid', (req, res) => {
Lecture.findOneBylectureid(req.params.lectureid)
.then((lecture) => {
if (!lecture) return res.status(404).send({ err: 'Lecture not found' });
res.send(`findOne successfully: ${lecture}`);
// Find One by lecturename
router.get('/lecturename/:lecturename', (req, res) => {
Lecture.findOneBylecturename(req.params.lecturename)
.then((Lecture) => {
if (!Lecture) return res.status(404).send({ err: 'Lecture not found' });
res.send(`findOne successfully: ${Lecture}`);
})
.catch(err => res.status(500).send(err));
});
// Create new lecture document
// Create new Lecture document
router.post('/', (req, res) => {
console.log(req.body)
Lecture.create(req.body)
.then(lecture => res.send(lecture))
.then(Lecture => res.send(Lecture))
.catch(err => res.status(500).send(err));
});
// Update by lectureid
router.put('/lectureid/:lectureid', (req, res) => {
Lecture.updateBylectureid(req.params.lectureid, req.body)
.then(lecture => res.send(lecture))
// Update by lecturename
router.put('/lecturename/:lecturename', (req, res) => {
Lecture.updateBylecturename(req.params.lecturename, req.body)
.then(Lecture => res.send(Lecture))
.catch(err => res.status(500).send(err));
});
// Delete by lectureid
router.delete('/lectureid/:lectureid', (req, res) => {
Lecture.deleteBylectureid(req.params.lectureid)
// Delete by lecturename
router.delete('/lecturename/:lecturename', (req, res) => {
Lecture.deleteBylecturename(req.params.lecturename)
.then(() => res.sendStatus(200))
.catch(err => res.status(500).send(err));
});
......
......@@ -4,41 +4,50 @@ const Review = require('../models/review');
// Find All
router.get('/', (req, res) => {
Review.findAll()
.then((reviews) => {
if (!reviews.length) return res.status(404).send({ err: 'Review not found' });
res.send(`find successfully: ${reviews}`);
.then((Reviews) => {
if (!Reviews.length) return res.status(404).send({ err: 'Review not found' });
res.send(`find successfully: ${Reviews}`);
})
.catch(err => res.status(500).send(err));
});
// Find One by reviewid
router.get('/reviewid/:reviewid', (req, res) => {
Review.findOneByreviewid(req.params.reviewid)
.then((review) => {
if (!review) return res.status(404).send({ err: 'Review not found' });
res.send(`findOne successfully: ${review}`);
// Find One by Reviewid
router.get('/lecturename/:lecturename', (req, res) => {
Review.findBylecturename(req.params.lecturename)
.then((Review) => {
if (!Review) return res.status(404).send({ err: 'Review not found' });
res.send(`findOne successfully: ${Review}`);
})
.catch(err => res.status(500).send(err));
});
// Create new review document
router.get('/proname/:proname', (req, res) => {
Review.findByproname(req.params.proname)
.then((Review) => {
if (!Review) return res.status(404).send({ err: 'Review not found' });
res.send(`findOne successfully: ${Review}`);
})
.catch(err => res.status(500).send(err));
});
// Create new Review document
router.post('/', (req, res) => {
console.log(req.body)
Review.create(req.body)
.then(review => res.send(review))
.then(Review => res.send(Review))
.catch(err => res.status(500).send(err));
});
// Update by reviewid
router.put('/reviewid/:reviewid', (req, res) => {
Review.updateByreviewid(req.params.reviewid, req.body)
.then(review => res.send(review))
// Update by lecturename
router.put('/lecturename/:lecturename', (req, res) => {
Review.updateBylecturename(req.params.lecturename, req.body)
.then(Review => res.send(Review))
.catch(err => res.status(500).send(err));
});
// Delete by reviewid
router.delete('/reviewid/:reviewid', (req, res) => {
Review.deleteByreviewid(req.params.reviewid)
// Delete by lecturename
router.delete('/lecturename/:lecturename', (req, res) => {
Review.deleteBylecturename(req.params.lecturename)
.then(() => res.sendStatus(200))
.catch(err => res.status(500).send(err));
});
......

334 KB