Ubuntu

temp

...@@ -8,11 +8,14 @@ const HTTPS = require('https'); ...@@ -8,11 +8,14 @@ const HTTPS = require('https');
8 const domain = "2020105648.oss2021.tk" 8 const domain = "2020105648.oss2021.tk"
9 const sslport = 23023; 9 const sslport = 23023;
10 const bodyParser = require('body-parser'); 10 const bodyParser = require('body-parser');
11 +const axios = require('axios')
12 +const cheerio = require('cheerio')
11 var app = express(); 13 var app = express();
12 -//var lan = "en" 14 +var cron = require('node-cron');
13 app.use(bodyParser.json()); 15 app.use(bodyParser.json());
14 16
15 17
18 +
16 app.post('/hook', function (req, res) { 19 app.post('/hook', function (req, res) {
17 20
18 var eventObj = req.body.events[0]; 21 var eventObj = req.body.events[0];
...@@ -25,18 +28,20 @@ app.post('/hook', function (req, res) { ...@@ -25,18 +28,20 @@ app.post('/hook', function (req, res) {
25 console.log('[request source] ', eventObj.source); 28 console.log('[request source] ', eventObj.source);
26 console.log('[request message]', eventObj.message); 29 console.log('[request message]', eventObj.message);
27 30
28 - // if (eventObj.message.text == "영어"){ 31 +
29 - // lan = "en" 32 + cron.schedule('*/5 * * * *', () => {
30 - // } 33 + const temp = axios.get(`https://finance.naver.com/item/main.nhn?code=${stock_code}%22`).then(
31 - // else if (eventObj.message.text == "일본어"){ 34 + res => {
32 - // lan = "ja" 35 + let urList = [];
33 - // } 36 + const $ = cheerio.load(res.data)
34 - // else if (eventObj.message.text == "프랑스어"){ 37 + const $bodyList = $("dl.blind").children("dd").text();
35 - // lan = "fr" 38 + const result = $bodyList.slice(73, 80) // 실시간으로 변하는 주식 가격 scrape
36 - // } 39 + console.log(result)
37 - // else{ 40 + }
38 - // trans(eventObj.replyToken, eventObj.message.text); 41 + )
39 - // } 42 + });
43 +
44 +
40 request.post( 45 request.post(
41 { 46 {
42 url: TARGET_URL, 47 url: TARGET_URL,
......
...@@ -55,6 +55,14 @@ ...@@ -55,6 +55,14 @@
55 "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", 55 "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
56 "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==" 56 "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
57 }, 57 },
58 + "axios": {
59 + "version": "0.21.1",
60 + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
61 + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
62 + "requires": {
63 + "follow-redirects": "^1.10.0"
64 + }
65 + },
58 "bcrypt-pbkdf": { 66 "bcrypt-pbkdf": {
59 "version": "1.0.2", 67 "version": "1.0.2",
60 "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", 68 "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
...@@ -80,6 +88,11 @@ ...@@ -80,6 +88,11 @@
80 "type-is": "~1.6.17" 88 "type-is": "~1.6.17"
81 } 89 }
82 }, 90 },
91 + "boolbase": {
92 + "version": "1.0.0",
93 + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
94 + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
95 + },
83 "bytes": { 96 "bytes": {
84 "version": "3.1.0", 97 "version": "3.1.0",
85 "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", 98 "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
...@@ -90,6 +103,32 @@ ...@@ -90,6 +103,32 @@
90 "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", 103 "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
91 "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" 104 "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
92 }, 105 },
106 + "cheerio": {
107 + "version": "1.0.0-rc.9",
108 + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.9.tgz",
109 + "integrity": "sha512-QF6XVdrLONO6DXRF5iaolY+odmhj2CLj+xzNod7INPWMi/x9X4SOylH0S/vaPpX+AUU6t04s34SQNh7DbkuCng==",
110 + "requires": {
111 + "cheerio-select": "^1.4.0",
112 + "dom-serializer": "^1.3.1",
113 + "domhandler": "^4.2.0",
114 + "htmlparser2": "^6.1.0",
115 + "parse5": "^6.0.1",
116 + "parse5-htmlparser2-tree-adapter": "^6.0.1",
117 + "tslib": "^2.2.0"
118 + }
119 + },
120 + "cheerio-select": {
121 + "version": "1.5.0",
122 + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.5.0.tgz",
123 + "integrity": "sha512-qocaHPv5ypefh6YNxvnbABM07KMxExbtbfuJoIie3iZXX1ERwYmJcIiRrr9H05ucQP1k28dav8rpdDgjQd8drg==",
124 + "requires": {
125 + "css-select": "^4.1.3",
126 + "css-what": "^5.0.1",
127 + "domelementtype": "^2.2.0",
128 + "domhandler": "^4.2.0",
129 + "domutils": "^2.7.0"
130 + }
131 + },
93 "combined-stream": { 132 "combined-stream": {
94 "version": "1.0.8", 133 "version": "1.0.8",
95 "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 134 "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
...@@ -126,6 +165,23 @@ ...@@ -126,6 +165,23 @@
126 "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 165 "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
127 "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" 166 "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
128 }, 167 },
168 + "css-select": {
169 + "version": "4.1.3",
170 + "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.1.3.tgz",
171 + "integrity": "sha512-gT3wBNd9Nj49rAbmtFHj1cljIAOLYSX1nZ8CB7TBO3INYckygm5B7LISU/szY//YmdiSLbJvDLOx9VnMVpMBxA==",
172 + "requires": {
173 + "boolbase": "^1.0.0",
174 + "css-what": "^5.0.0",
175 + "domhandler": "^4.2.0",
176 + "domutils": "^2.6.0",
177 + "nth-check": "^2.0.0"
178 + }
179 + },
180 + "css-what": {
181 + "version": "5.0.1",
182 + "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.1.tgz",
183 + "integrity": "sha512-FYDTSHb/7KXsWICVsxdmiExPjCfRC4qRFBdVwv7Ax9hMnvMmEjP9RfxTEZ3qPZGmADDn2vAKSo9UcN1jKVYscg=="
184 + },
129 "dashdash": { 185 "dashdash": {
130 "version": "1.14.1", 186 "version": "1.14.1",
131 "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", 187 "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
...@@ -157,6 +213,39 @@ ...@@ -157,6 +213,39 @@
157 "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 213 "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
158 "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 214 "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
159 }, 215 },
216 + "dom-serializer": {
217 + "version": "1.3.2",
218 + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
219 + "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==",
220 + "requires": {
221 + "domelementtype": "^2.0.1",
222 + "domhandler": "^4.2.0",
223 + "entities": "^2.0.0"
224 + }
225 + },
226 + "domelementtype": {
227 + "version": "2.2.0",
228 + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz",
229 + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A=="
230 + },
231 + "domhandler": {
232 + "version": "4.2.0",
233 + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz",
234 + "integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==",
235 + "requires": {
236 + "domelementtype": "^2.2.0"
237 + }
238 + },
239 + "domutils": {
240 + "version": "2.7.0",
241 + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz",
242 + "integrity": "sha512-8eaHa17IwJUPAiB+SoTYBo5mCdeMgdcAoXJ59m6DT1vw+5iLS3gNoqYaRowaBKtGVrOF1Jz4yDTgYKLK2kvfJg==",
243 + "requires": {
244 + "dom-serializer": "^1.0.1",
245 + "domelementtype": "^2.2.0",
246 + "domhandler": "^4.2.0"
247 + }
248 + },
160 "ecc-jsbn": { 249 "ecc-jsbn": {
161 "version": "0.1.2", 250 "version": "0.1.2",
162 "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", 251 "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
...@@ -176,6 +265,11 @@ ...@@ -176,6 +265,11 @@
176 "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 265 "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
177 "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" 266 "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
178 }, 267 },
268 + "entities": {
269 + "version": "2.2.0",
270 + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz",
271 + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A=="
272 + },
179 "escape-html": { 273 "escape-html": {
180 "version": "1.0.3", 274 "version": "1.0.3",
181 "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 275 "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
...@@ -257,6 +351,11 @@ ...@@ -257,6 +351,11 @@
257 "unpipe": "~1.0.0" 351 "unpipe": "~1.0.0"
258 } 352 }
259 }, 353 },
354 + "follow-redirects": {
355 + "version": "1.14.1",
356 + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz",
357 + "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg=="
358 + },
260 "forever-agent": { 359 "forever-agent": {
261 "version": "0.6.1", 360 "version": "0.6.1",
262 "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", 361 "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
...@@ -304,6 +403,17 @@ ...@@ -304,6 +403,17 @@
304 "har-schema": "^2.0.0" 403 "har-schema": "^2.0.0"
305 } 404 }
306 }, 405 },
406 + "htmlparser2": {
407 + "version": "6.1.0",
408 + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz",
409 + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==",
410 + "requires": {
411 + "domelementtype": "^2.0.1",
412 + "domhandler": "^4.0.0",
413 + "domutils": "^2.5.2",
414 + "entities": "^2.0.0"
415 + }
416 + },
307 "http-errors": { 417 "http-errors": {
308 "version": "1.7.2", 418 "version": "1.7.2",
309 "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", 419 "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
...@@ -418,6 +528,19 @@ ...@@ -418,6 +528,19 @@
418 "mime-db": "1.48.0" 528 "mime-db": "1.48.0"
419 } 529 }
420 }, 530 },
531 + "moment": {
532 + "version": "2.29.1",
533 + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
534 + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
535 + },
536 + "moment-timezone": {
537 + "version": "0.5.33",
538 + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz",
539 + "integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==",
540 + "requires": {
541 + "moment": ">= 2.9.0"
542 + }
543 + },
421 "ms": { 544 "ms": {
422 "version": "2.0.0", 545 "version": "2.0.0",
423 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 546 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
...@@ -428,6 +551,22 @@ ...@@ -428,6 +551,22 @@
428 "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", 551 "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
429 "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" 552 "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
430 }, 553 },
554 + "node-cron": {
555 + "version": "3.0.0",
556 + "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.0.tgz",
557 + "integrity": "sha512-DDwIvvuCwrNiaU7HEivFDULcaQualDv7KoNlB/UU1wPW0n1tDEmBJKhEIE6DlF2FuoOHcNbLJ8ITL2Iv/3AWmA==",
558 + "requires": {
559 + "moment-timezone": "^0.5.31"
560 + }
561 + },
562 + "nth-check": {
563 + "version": "2.0.0",
564 + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz",
565 + "integrity": "sha512-i4sc/Kj8htBrAiH1viZ0TgU8Y5XqCaV/FziYK6TBczxmeKm3AEFWqqF3195yKudrarqy7Zu80Ra5dobFjn9X/Q==",
566 + "requires": {
567 + "boolbase": "^1.0.0"
568 + }
569 + },
431 "oauth-sign": { 570 "oauth-sign": {
432 "version": "0.9.0", 571 "version": "0.9.0",
433 "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", 572 "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
...@@ -441,6 +580,19 @@ ...@@ -441,6 +580,19 @@
441 "ee-first": "1.1.1" 580 "ee-first": "1.1.1"
442 } 581 }
443 }, 582 },
583 + "parse5": {
584 + "version": "6.0.1",
585 + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
586 + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
587 + },
588 + "parse5-htmlparser2-tree-adapter": {
589 + "version": "6.0.1",
590 + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz",
591 + "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==",
592 + "requires": {
593 + "parse5": "^6.0.1"
594 + }
595 + },
444 "parseurl": { 596 "parseurl": {
445 "version": "1.3.3", 597 "version": "1.3.3",
446 "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 598 "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
...@@ -618,6 +770,11 @@ ...@@ -618,6 +770,11 @@
618 "punycode": "^2.1.1" 770 "punycode": "^2.1.1"
619 } 771 }
620 }, 772 },
773 + "tslib": {
774 + "version": "2.2.0",
775 + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz",
776 + "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w=="
777 + },
621 "tunnel-agent": { 778 "tunnel-agent": {
622 "version": "0.6.0", 779 "version": "0.6.0",
623 "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", 780 "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
......