장수창

added news crawling

......@@ -3,7 +3,9 @@ const request = require('request');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast'
const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast'
const TOKEN = ''
const TOKEN = 'yHHIa8B3iw072bvTv0u4RtmEEN1wrNi7onqWpKqoU/ceH4foYgIo6iHJbuZuepE72sMymCx7U761J1M/8So3gCWWRR34zvPp9YZpUFn07/hLSflcK6obioMeD6o108II/pvqfc/rZ+042re0ayIxIgdB04t89/1O/w1cDnyilFU='
const NAVER_NEWS_ID = ''
const NAVER_NEWS_SECRET = ''
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
......@@ -177,6 +179,33 @@ function broadcast(){
// console.log(body)
// });
function news_Crawling() {
var news_Title = ['title1', 'title2', 'title3', 'title4', 'title5']
var news_Link = ['link1', 'link2', 'link3', 'link4', 'link5']
request.get({
url: 'https://openapi.naver.com/v1/search/news',
qs: {
query: '코로나 19', // 검색어
start: 1, // 검색 시작 위치
display: 10, // 가져올 뉴스 개수
sort: 'sim', // date or sim
},
headers: {
'X-Naver-Client-Id': NAVER_NEWS_ID,
'X-Naver-Client-Secret': NAVER_NEWS_SECRET
}
}, function (err, res, body) {
let json = JSON.parse(body) //json으로 파싱
for (var i = 0; i < 5; i++) {
news_Title[i] = json.items[i].title.replace('<b>', '').replace('</b>', '').replace('&quot;', '').replace('&quot;', '');
news_Link[i] = json.items[i].link;
}
})
}
try {
const option = {
ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
......