Showing
1 changed file
with
30 additions
and
1 deletions
... | @@ -3,7 +3,9 @@ const request = require('request'); | ... | @@ -3,7 +3,9 @@ const request = require('request'); |
3 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 3 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
4 | const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' | 4 | const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' |
5 | const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' | 5 | const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' |
6 | -const TOKEN = '' | 6 | +const TOKEN = 'yHHIa8B3iw072bvTv0u4RtmEEN1wrNi7onqWpKqoU/ceH4foYgIo6iHJbuZuepE72sMymCx7U761J1M/8So3gCWWRR34zvPp9YZpUFn07/hLSflcK6obioMeD6o108II/pvqfc/rZ+042re0ayIxIgdB04t89/1O/w1cDnyilFU=' |
7 | +const NAVER_NEWS_ID = '' | ||
8 | +const NAVER_NEWS_SECRET = '' | ||
7 | const fs = require('fs'); | 9 | const fs = require('fs'); |
8 | const path = require('path'); | 10 | const path = require('path'); |
9 | const HTTPS = require('https'); | 11 | const HTTPS = require('https'); |
... | @@ -177,6 +179,33 @@ function broadcast(){ | ... | @@ -177,6 +179,33 @@ function broadcast(){ |
177 | // console.log(body) | 179 | // console.log(body) |
178 | // }); | 180 | // }); |
179 | 181 | ||
182 | +function news_Crawling() { | ||
183 | + | ||
184 | + var news_Title = ['title1', 'title2', 'title3', 'title4', 'title5'] | ||
185 | + var news_Link = ['link1', 'link2', 'link3', 'link4', 'link5'] | ||
186 | + request.get({ | ||
187 | + url: 'https://openapi.naver.com/v1/search/news', | ||
188 | + qs: { | ||
189 | + query: '코로나 19', // 검색어 | ||
190 | + start: 1, // 검색 시작 위치 | ||
191 | + display: 10, // 가져올 뉴스 개수 | ||
192 | + sort: 'sim', // date or sim | ||
193 | + }, | ||
194 | + headers: { | ||
195 | + 'X-Naver-Client-Id': NAVER_NEWS_ID, | ||
196 | + 'X-Naver-Client-Secret': NAVER_NEWS_SECRET | ||
197 | + } | ||
198 | + }, function (err, res, body) { | ||
199 | + let json = JSON.parse(body) //json으로 파싱 | ||
200 | + | ||
201 | + for (var i = 0; i < 5; i++) { | ||
202 | + news_Title[i] = json.items[i].title.replace('<b>', '').replace('</b>', '').replace('"', '').replace('"', ''); | ||
203 | + news_Link[i] = json.items[i].link; | ||
204 | + } | ||
205 | + }) | ||
206 | +} | ||
207 | + | ||
208 | + | ||
180 | try { | 209 | try { |
181 | const option = { | 210 | const option = { |
182 | ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | 211 | ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ... | ... |
-
Please register or login to post a comment