Skip to content

Commit

Permalink
menu modified
Browse files Browse the repository at this point in the history
  • Loading branch information
martinuslee committed Mar 15, 2021
1 parent c0b1c80 commit 78111f1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions router/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 78111f1

Please sign in to comment.