khu.js 955 Bytes
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();
})();