Skip to content

Commit

Permalink
annotation menu
Browse files Browse the repository at this point in the history
  • Loading branch information
martinuslee committed Mar 15, 2021
1 parent cf3f866 commit 92e53a5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions router/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ const express = require("express");
const apiRouter = express.Router();
const axios = require("axios"); //html로 웹자료를 get
const cheerio = require("cheerio"); //html을 JS로 변환

let $href = [];

apiRouter.post("/menu", function (req, res) {
console.log(req.body);
//console.log(req.body);

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 = $("a"); //<a> 태그 전부 가져옴
$(links).each((i, link) => {
//console.log(i + ' : ' + $(link).text() +': '+$(link).attr('href')+ '\n');
if ($(link).text() === "교직원식당 주간 메뉴")
$href=($(link).attr("href"));
if ($(link).text() === "교직원식당 주간 메뉴") //a 태그에 텍스트가 교직원식당 주간 메뉴인 부분 찾기
$href=($(link).attr("href")); // 찾았으면 href 속성 링크 가져옴
});
console.log("https://sejong.korea.ac.kr" + $href);
});
Expand Down

0 comments on commit 92e53a5

Please sign in to comment.