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-20 04:00:23 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f6bbc8860c8145678a66019d935a301bfd66e947
f6bbc886
1 parent
7bff190f
added yongin crawling
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
51 deletions
nodejs/app.js
nodejs/app.js
View file @
f6bbc88
...
...
@@ -2,11 +2,12 @@ var express = require('express');
const
request
=
require
(
'request'
);
const
axios
=
require
(
"axios"
);
const
cheerio
=
require
(
"cheerio"
);
const
url
=
"http://ncov.mohw.go.kr/"
;
// 질병관리본부 url
const
ncov_url
=
"http://ncov.mohw.go.kr/"
;
// 질병관리본부 url
const
yongin_url
=
'http://www.yongin.go.kr/health/ictsd/INC_selectIctsdPatntList.do?q_currPage=1&q_rowPerPage=10&_=1592578382959'
;
// 용인시
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
=
'
///////
'
const
NAVER_NEWS_ID
=
''
const
NAVER_NEWS_SECRET
=
''
const
fs
=
require
(
'fs'
);
...
...
@@ -14,10 +15,10 @@ const path = require('path');
const
HTTPS
=
require
(
'https'
);
const
domain
=
"www.osschatbot2020.tk"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
var
app
=
express
();
// broadcast route
var
period_broadcast
=
50000
;
var
count_broadcast
=
0
;
...
...
@@ -57,10 +58,10 @@ app.post('/hook', function (req, res) {
res
.
sendStatus
(
200
);
});
//reply
//
reply
function
replyNationWide
(
eventObj
)
{
//read status
request
.
post
(
url
,
function
(
err
,
res
,
body
)
{
request
.
post
(
ncov_
url
,
function
(
err
,
res
,
body
)
{
const
$
=
cheerio
.
load
(
body
)
let
parentTag
=
$
(
"div.liveNum ul.liveNum li"
);
...
...
@@ -115,7 +116,7 @@ function replyNationWide(eventObj) {
}
//hello
//
hello
function
hello
(
eventObj
)
{
request
.
post
(
...
...
@@ -140,6 +141,10 @@ function hello(eventObj) {
"text"
:
"코로나 19 관련 뉴스는 '뉴스'를 타이핑 해주세요."
},
{
"type"
:
"text"
,
"text"
:
"감사합니다."
},
{
"type"
:
"sticker"
,
"packageId"
:
"11539"
,
"stickerId"
:
"52114110"
...
...
@@ -152,55 +157,49 @@ function hello(eventObj) {
});
}
// Broadcast
// Broadcast
yongin
function
broadcast
(){
request
.
post
(
yongin_url
,
function
(
err
,
res
,
body
)
{
request
.
post
(
{
url
:
BROAD_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"Hello, user"
},
{
"type"
:
"text"
,
"text"
:
"May I help you?"
}
]
const
$
=
cheerio
.
load
(
body
)
let
parentTag
=
$
(
"div.view_content"
);
let
resultArr
=
[];
parentTag
.
each
(
function
(
i
,
elem
)
{
let
itemObj
=
{
text
:
$
(
this
).
find
(
"p"
).
text
(),
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
resultArr
.
push
(
itemObj
);
})
var
fs
=
require
(
'fs'
);
var
array
=
fs
.
readFileSync
(
'yongin.txt'
).
toString
().
split
(
"\n"
);
request
.
post
(
{
url
:
BROAD_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"용인시 확진자의 동선이 공개되었습니다."
},
{
"type"
:
"sticker"
,
"packageId"
:
"11539"
,
"stickerId"
:
"52114110"
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
// Multicast User
// request.post(
// {
// url: MULTI_TARGET_URL,
// headers: {
// 'Authorization': `Bearer ${TOKEN}`
// },
// json: {
// "to": [`${USER_ID}`],
// "messages":[
// {
// "type":"text",
// "text":"용인시"
// },
// {
// "type":"text",
// "text":"용인시"
// }
// ]
// }
// },(error, response, body) => {
// console.log(body)
// });
})
}
//reply news
function
replyNews
(
eventObj
)
{
...
...
Please
register
or
login
to post a comment