SW0000J

연합뉴스(app.js 수정)

Showing 1 changed file with 4 additions and 2 deletions
1 const axios = require("axios"); 1 const axios = require("axios");
2 const cheerio = require("cheerio"); 2 const cheerio = require("cheerio");
3 3
4 +const url = "https://www.yna.co.kr/sports/baseball"
5 +
4 const getHtml = async () => { 6 const getHtml = async () => {
5 try { 7 try {
6 - return await axios.get("https://www.yna.co.kr/sports/baseball"); 8 + return await axios.get(url);
7 } catch (error) { 9 } catch (error) {
8 console.error(error); 10 console.error(error);
9 } 11 }
...@@ -21,7 +23,7 @@ getHtml() ...@@ -21,7 +23,7 @@ getHtml()
21 image_url: $(this).find('figure.img-con a').attr('href'), 23 image_url: $(this).find('figure.img-con a').attr('href'),
22 url: $(this).find('div.news-con a').attr('href'), 24 url: $(this).find('div.news-con a').attr('href'),
23 title: $(this).find('div.news-con strong').text(), 25 title: $(this).find('div.news-con strong').text(),
24 - summary: $(this).find('div.news-con p').text().slice(0, -29) 26 + summary: $(this).find('div.news-con p').text()
25 }; 27 };
26 //console.log(ulList[i]) // list object checking code 28 //console.log(ulList[i]) // list object checking code
27 }); 29 });
......