Toggle navigation
Toggle navigation
This project
Loading...
Sign in
장수창
/
COVID19_Information_Chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
장수창
2020-06-19 20:59:07 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
31acb31966ec05b30202cb6aee3590f686edd4ff
31acb319
1 parent
d25b7145
added news crawling
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletions
nodejs/app.js
nodejs/app.js
View file @
31acb31
...
...
@@ -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
(
'"'
,
''
).
replace
(
'"'
,
''
);
news_Link
[
i
]
=
json
.
items
[
i
].
link
;
}
})
}
try
{
const
option
=
{
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
domain
+
'/fullchain.pem'
),
...
...
Please
register
or
login
to post a comment