diff --git a/router/menu.js b/router/menu.js index 25815c9..136e389 100644 --- a/router/menu.js +++ b/router/menu.js @@ -3,26 +3,26 @@ const apiRouter = express.Router(); const axios = require("axios"); //html로 웹자료를 get const cheerio = require("cheerio"); //html을 JS로 변환 -let $href = []; -axios - .get(`https://sejong.korea.ac.kr/campuslife/facilities/dining/weeklymenu`) - .then((response) => { - const $ = cheerio.load(response.data); - // $(".buttonGo floatR").each((index, item) => { - // menulink = item.attribs.href; - // }); - links = $("a"); - $(links).each((i, link) => { - //console.log(i + ' : ' + $(link).text() +': '+$(link).attr('href')+ '\n'); - if ($(link).text() === "교직원식당 주간 메뉴") - $href.push($(link).attr("href")); - }); - console.log("https://sejong.korea.ac.kr" + $href); - }); - apiRouter.post("/menu", function (req, res) { console.log(req.body); + let $href = []; + axios + .get(`https://sejong.korea.ac.kr/campuslife/facilities/dining/weeklymenu`) + .then((response) => { + const $ = cheerio.load(response.data); + // $(".buttonGo floatR").each((index, item) => { + // menulink = item.attribs.href; + // }); + links = $("a"); + $(links).each((i, link) => { + //console.log(i + ' : ' + $(link).text() +': '+$(link).attr('href')+ '\n'); + if ($(link).text() === "교직원식당 주간 메뉴") + $href.push($(link).attr("href")); + }); + console.log("https://sejong.korea.ac.kr" + $href); + }); + const responseBody = { version: "2.0", template: {