Showing
2 changed files
with
37 additions
and
9 deletions
... | @@ -11,8 +11,11 @@ const bodyParser = require('body-parser'); | ... | @@ -11,8 +11,11 @@ const bodyParser = require('body-parser'); |
11 | const axios = require('axios') | 11 | const axios = require('axios') |
12 | const cheerio = require('cheerio') | 12 | const cheerio = require('cheerio') |
13 | var app = express(); | 13 | var app = express(); |
14 | +var cron = require('node-cron'); | ||
14 | app.use(bodyParser.json()); | 15 | app.use(bodyParser.json()); |
15 | 16 | ||
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,15 +28,19 @@ app.post('/hook', function (req, res) { | ... | @@ -25,15 +28,19 @@ 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 | - const temp = axios.get(`https://finance.naver.com/item/main.nhn?code=${stock_code}%22`).then( | 31 | + |
29 | - res => { | 32 | + cron.schedule('*/5 * * * *', () => { |
30 | - let urList = []; | 33 | + const temp = axios.get(`https://finance.naver.com/item/main.nhn?code=${stock_code}%22`).then( |
31 | - const $ = cheerio.load(res.data) | 34 | + res => { |
32 | - const $bodyList = $("dl.blind").children("dd").text(); | 35 | + let urList = []; |
33 | - const result = $bodyList.slice(73, 80) // 실시간으로 변하는 주식 가격 scrape | 36 | + const $ = cheerio.load(res.data) |
34 | - console.log(result) | 37 | + const $bodyList = $("dl.blind").children("dd").text(); |
35 | - } | 38 | + const result = $bodyList.slice(73, 80) // 실시간으로 변하는 주식 가격 scrape |
36 | - ) | 39 | + console.log(result) |
40 | + } | ||
41 | + ) | ||
42 | + }); | ||
43 | + | ||
37 | 44 | ||
38 | request.post( | 45 | request.post( |
39 | { | 46 | { | ... | ... |
... | @@ -528,6 +528,19 @@ | ... | @@ -528,6 +528,19 @@ |
528 | "mime-db": "1.48.0" | 528 | "mime-db": "1.48.0" |
529 | } | 529 | } |
530 | }, | 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 | + }, | ||
531 | "ms": { | 544 | "ms": { |
532 | "version": "2.0.0", | 545 | "version": "2.0.0", |
533 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", | 546 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", |
... | @@ -538,6 +551,14 @@ | ... | @@ -538,6 +551,14 @@ |
538 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", | 551 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", |
539 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" | 552 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" |
540 | }, | 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 | + }, | ||
541 | "nth-check": { | 562 | "nth-check": { |
542 | "version": "2.0.0", | 563 | "version": "2.0.0", |
543 | "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz", | 564 | "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz", | ... | ... |
-
Please register or login to post a comment