ȸ¿ø

·Î±×ÀÎ

05¿ù 05ÀÏ (ÀÏ)

¼¿Å¬·´ ȨÃֽűÛ

¸ñ·Ï ´ÙÀ½±Û

·Î¶Ç N645 ´ç÷¹øÈ£ ¹× ºÎ°¡Á¤º¸ ÆĽÌ

Á¤µ¿È£3 Á¶È¸ : 3,332
1. °³¿ä

¡Ü ÀÛ¼ºÀÏ: 2021-09-07

¡Ü µû¶óÇϱ⠹æ½ÄÀ¸·Î ½Ç¹«¿¡ Àû¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

2. Ç÷§Æû

¡Ü µ¥ºñ¾È °è¿­

3. Çʼö ÇÁ·Î±×·¥

¡Ü NodeJS

4. NodeJS ¼³Ä¡

Memo. NodeJS ´Â ÀÚ¹Ù½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÑ ³×Æ®¿öÅ© ¾îÇø®ÄÉÀÌ¼Ç ¹× ½Ã½ºÅÛ ¾îÇø®ÄÉÀ̼ÇÀ» Á¦ÀÛÇÒ ¼ö ÀÖ´Â ÀÚ¹Ù½ºÅ©¸³Æ® ·±Å¸ÀÓ ¾îÇø®ÄÉÀÌ¼Ç ÀÔ´Ï´Ù.

apt list nodejs

apt install curl software-properties-common

curl -sL https://deb.nodesource.com/setup_14.x | bash -

apt list nodejs

apt install nodejs

node --version

npm --version

Memo. npm ¿¡ ºñÇØ º¸¾È°ú ¼º´ÉÀÌ Çâ»óµÈ ÆÐÅ°Áö ¸Å´ÏÀú¸¦ Àü¿ª ¼³Ä¡ÇÕ´Ï´Ù.

npm install -g yarn

yarn --version

5. ÇÁ·ÎÁ§Æ® »ý¼º

mkdir myproject

cd myproject

yarn init -y

6. NodeJS ¸¦ À§ÇÑ Çʼö ÆÐÅ°Áö ¼³Ä¡

Memo. À¥ ÄÁÅÙÃ÷ ¿äûÀ» À§ÇÑ ÆÐÅ°Áö ¼³Ä¡.

yarn add axios

Memo. À¥ ¿äû ÈÄ ÀÀ´äÇÑ html À» Çؼ®ÇÏ°í ÆĽÌÇÒ ¼ö ÀÖ´Â ÆÐÅ°Áö.
Memo. LottoN645 ¿¡¼­ Á¦°øÇÏ´Â API ¸¦ »ç¿ëÇÑ´Ù¸é cheerio ÆÐÅ°Áö°¡ ÇÊ¿äÇÏÁö ¾Ê½À´Ï´Ù.
Memo. LottoN645 API °¡ ÇÊ¿äÇϽźÐÀº ´ÙÀ½ ¸µÅ©¸¦ È®ÀÎÇϽʽÿÀ.
Memo. https://www.dhlottery.co.kr/common.do?method=getLottoNumber&drwNo=789

yarn add cheerio

Memo. LottoN645 ȨÆäÀÌÁö ÀÎÄÚµù ¹æ½ÄÀÌ EUC-KR À̹ǷΠÇÑ±Û ÀνÄÀÌ µÇÁö ¾Ê½À´Ï´Ù.
Memo. <ÀÚµ¿, ¹ÝÀÚµ¿, ¼öµ¿> Àοø¼ö¸¦ ÆĽÌÇÒ¶§ ÇѱÛÀνÄÀ» ÇؾßÇϹǷΠ´ÙÀ½ ÆÐÅ°Áö°¡ ÇÊ¿äÇÕ´Ï´Ù.

yarn add iconv-lite

7. index.js ÆÄÀÏ ÀÛ¼º

Memo. ÇÁ·ÎÁ§Æ® ÇÙ½É Äڵ尡 ÀÛ¼ºµÉ ÆÄÀÏ ÀÔ´Ï´Ù.

vi index.js

const axios = require("axios");
const cheer = require("cheerio");
const iconv = require("iconv-lite");

(async () => {
const webque = axios.create({
responseType: "arraybuffer",
reponseEncoding: "binary"
}),
n645Url = "https://dhlottery.co.kr/gameResult.do?method=byWin&drwNo=",
saleMoney = 1000;
async function get_lottoN645(inning = ''){
let resp;
try{
resp = await webque.get(n645Url + inning);
const $ = cheer.load(iconv.decode(resp.data, 'EUC-KR')),
root = $("#article"),
el1 = root.find(".win_result").children(),
n645 = {},
pt = /[^0-9]/g;
n645.inning = +el1.eq(0).text().replace(pt, '');
const m = el1.eq(1).text().match(/([0-9]{4}).*([0-9]{2}).*([0-9]{2})/);
n645.gDT = m[1] + "-" + m[2] + "-" + m[3];
const el2 = el1.eq(2).children();
const el3 = el2.eq(0).children().eq(1).children();
n645.N1 = +el3.eq(0).text();
n645.N2 = +el3.eq(1).text();
n645.N3 = +el3.eq(2).text();
n645.N4 = +el3.eq(3).text();
n645.N5 = +el3.eq(4).text();
n645.N6 = +el3.eq(5).text();
n645.NS = [n645.N1, n645.N2, n645.N3, n645.N4, n645.N5, n645.N6];
n645.NB = +el2.eq(1).children().eq(1).text();
const n645Info = {
inning: n645.inning,
W1_autoMark: 0,
W1_selfMark: 0,
W1_banMark: 0
};
const table = root.find(".tbl_data");
const rows = table.children().eq(3).children();
const row1 = rows.eq(0).children();
n645Info.W1_tMoney = +row1.eq(1).text().replace(pt, '');
n645Info.W1_wCnt = +row1.eq(2).text().replace(pt, '');
n645Info.W1_money = +row1.eq(3).text().replace(pt, '');
const row2 = rows.eq(1).children();
n645Info.W2_tMoney = +row2.eq(1).text().replace(pt, '');
n645Info.W2_wCnt = +row2.eq(2).text().replace(pt, '');
n645Info.W2_money = +row2.eq(3).text().replace(pt, '');
const row3 = rows.eq(2).children();
n645Info.W3_tMoney = +row3.eq(1).text().replace(pt, '');
n645Info.W3_wCnt = +row3.eq(2).text().replace(pt, '');
n645Info.W3_money = +row3.eq(3).text().replace(pt, '');
const row4 = rows.eq(3).children();
n645Info.W4_tMoney = +row4.eq(1).text().replace(pt, '');
n645Info.W4_wCnt = +row4.eq(2).text().replace(pt, '');
n645Info.W4_money = +row4.eq(3).text().replace(pt, '');
const row5 = rows.eq(4).children();
n645Info.W5_tMoney = +row5.eq(1).text().replace(pt, '');
n645Info.W5_wCnt = +row5.eq(2).text().replace(pt, '');
n645Info.W5_money = +row5.eq(3).text().replace(pt, '');
const bigo = row1.eq(5).html();
const m1 = bigo.match(/ÀÚµ¿([0-9]+)/);
if(m1) n645Info.W1_autoMark = +m1[1];
const m2 = bigo.match(/¼öµ¿([0-9]+)/);
if(m2) n645Info.W1_selfMark = +m2[1];
const m3 = bigo.match(/¹ÝÀÚµ¿([0-9]+)/);
if(m3) n645Info.W1_banMark = +m3[1];
n645Info.tSaleMoney = +table.next().children().eq(1).text().replace(pt, '');
n645Info.tGameCnt = n645Info.tSaleMoney / saleMoney;
return {n645, n645Info};
}catch(e){
return {err: e};
}
}
const result = await get_lottoN645();
if(result.err) return console.error(result.err);
console.log("result", result);
})();

:wq

8. ½ÇÇà

node .
PC¹öÁ¯À¸·Î È®ÀÎÇϱâ
souldev8 22.05.04 08:40
¿Í¿ì node ·Î Ä£ÀýÈ÷ ¾Ë·ÁÁּ̳׿ä
¸ÇÀ§ ¸ñ·Ï ´ÙÀ½±Û

±âŸÇÁ·Î±×·¥

ºÐ·ù
Total 71
List
12345

HOME ·Î±×ÀÎ PC¹öÀü °í°´¼¾ÅÍ

© SellClub Mobile