init
This commit is contained in:
BIN
.cron.js.swp
Normal file
BIN
.cron.js.swp
Normal file
Binary file not shown.
113
.gitignore
vendored
Normal file
113
.gitignore
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# database
|
||||
*.sqlite
|
||||
|
||||
# package-json
|
||||
package-json.lock
|
||||
|
||||
# bun deploy file
|
||||
node_modules.bun
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "pwa-node",
|
||||
"request": "launch",
|
||||
"name": "Launch Node Program",
|
||||
"program": "${file}"
|
||||
}
|
||||
]
|
||||
}
|
||||
21514
20251127.txt
Normal file
21514
20251127.txt
Normal file
File diff suppressed because one or more lines are too long
743
cron.js
Normal file
743
cron.js
Normal file
@@ -0,0 +1,743 @@
|
||||
const axios = require("axios");
|
||||
const FormData = require("form-data");
|
||||
const qs = require("querystring");
|
||||
const cheerio = require("cheerio");
|
||||
const _ = require("lodash");
|
||||
const fs = require("fs/promises");
|
||||
const Aigle = require("aigle");
|
||||
const moment = require("moment");
|
||||
const sleep = require("atomic-sleep");
|
||||
const iconv = require("iconv-lite");
|
||||
const { delay } = require("lodash");
|
||||
const cron = require("node-cron");
|
||||
const LZString = require("lz-string");
|
||||
|
||||
Aigle.mixin(_);
|
||||
|
||||
// let test = {}
|
||||
// test.deliveryInfo = ['우체국택배', '7865401358906']
|
||||
// checkPostOffice(test)
|
||||
|
||||
// if (!process.argv[2]) {
|
||||
// console.log('사용방법')
|
||||
// console.log('node test.js 완료일자 start|check')
|
||||
// console.log(moment(new Date()).subtract(1, 'day').format('YYYY-MM-DD'))
|
||||
// return false
|
||||
// }
|
||||
|
||||
// if (!process.argv[3]) {
|
||||
// console.log('사용방법')
|
||||
// console.log('node test.js 완료일자 start|check')
|
||||
// return false
|
||||
// }
|
||||
|
||||
let data = {
|
||||
// username: "aa509004",
|
||||
// password: "daesik102049@@",
|
||||
username: "JH1204",
|
||||
password: "12345",
|
||||
};
|
||||
|
||||
const WRITE_END_DATE = true;
|
||||
const END_DATE = moment(new Date()).subtract(1, "day").format("YYYY-MM-DD");
|
||||
|
||||
// let loginForm = new FormData()
|
||||
// loginForm.append('app_name',"크롬(chrome)")
|
||||
// loginForm.append('from',"pc")
|
||||
// loginForm.append('nhoj',"home3470")
|
||||
// loginForm.append('mluap',"5aee9b59574a3b9666400f9ea3ee5b4b")
|
||||
|
||||
let loginObj = {
|
||||
app_name: "크롬(chrome)",
|
||||
from: "pc",
|
||||
nhoj: "JH1204",
|
||||
mluap: "827ccb0eea8a706c4c34a16891f84e7b",
|
||||
};
|
||||
|
||||
let cookie = [
|
||||
"ds_yn=y; save_id=aa509004; ccn172=84ed141356cb95148bac1afb88b5ddaa663fd58c36ffa2f5ea536285791c754bb938f93336c4c72ac18203fc2ce5bcb004baf34ab6953952a1cb4bbf7be5186f8340853bef8e73ef33bfbdba0d2ce833e5acf7fe074a6d3bb79aa47e4de0dd120ac8821e605e23838cc4d70f65aa4186ed66ee406e0c003514e8a7edb3a7a47f3e5fe9c9ea44467ed469ccfd3fc368da37267711de8f9571b504605793f4c11a32694799eebc8c456ecd7e631a854cbc5cb586ac65a9c1965b0f04fe477e6aec127d7ecb8a0397d811ed70064f5fa09c",
|
||||
"ds_yn=y; path=/; domain=hyun.bizmax.net; HttpOnly",
|
||||
];
|
||||
|
||||
let hanjinCookie = [];
|
||||
|
||||
async function createCookie() {
|
||||
await axios.get("https://www.hanjin.co.kr").then((response) => {
|
||||
console.log(response.headers["set-cookie"]);
|
||||
hanjinCookie = response.headers["set-cookie"];
|
||||
});
|
||||
}
|
||||
|
||||
let bodyFormData = new URLSearchParams();
|
||||
bodyFormData.set("form", JSON.stringify(loginObj));
|
||||
|
||||
function setCookie() {
|
||||
console.log("setCookie");
|
||||
return new Promise((resolve) => {
|
||||
axios
|
||||
.post(
|
||||
"https://hyun.bizmax.net/login_pcs_jr.php",
|
||||
qs.stringify(loginObj),
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Length": "96",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Cookie: "ds_yn=y; save_id=home3470",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: `https://hyun.bizmax.net/main/?${Date.now()}`,
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
// console.log(response)
|
||||
cookie = response.headers["set-cookie"];
|
||||
resolve(response.headers["set-cookie"]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function getLists(page) {
|
||||
let searchDate = {
|
||||
start: moment(new Date()).subtract(1, "month").format("YYYY-MM-DD"),
|
||||
// start: moment(new Date()).subtract(6, 'day').format('YYYY-MM-DD'),
|
||||
end: moment(new Date()).subtract(1, "day").format("YYYY-MM-DD"),
|
||||
};
|
||||
console.log(searchDate);
|
||||
|
||||
let reqObj = {
|
||||
state: 8,
|
||||
_content_only: "y",
|
||||
_ihl: "n",
|
||||
_ihr: "n",
|
||||
clm: 0,
|
||||
use_date_1: "a.reg_date",
|
||||
data_orderby: "a.reg_date",
|
||||
start_date_1: searchDate.start,
|
||||
end_date_1: searchDate.end,
|
||||
excel_ext: "csv",
|
||||
mode: "search",
|
||||
page: page,
|
||||
post_size: 1000,
|
||||
sale_name_clm_q: "4b40dd075943efaf446b15696ebec5e3",
|
||||
site_gubun: "pc",
|
||||
tbs_end_date: "2021-02-26",
|
||||
tbs_start_date: "2021-02-26",
|
||||
};
|
||||
|
||||
// s_customer_group=&s_customer_group_src=&s_customer_group_dsp=-+%EA%B3%A0%EA%B0%9D%EA%B7%B8%EB%A3%B9&s_open_branch_prim=&s_open_branch_prim_src=&s_open_branch_prim_dsp=-+%EA%B0%9C%ED%86%B5%EC%B2%98&s_sale_branch_prim=&s_sale_branch_prim_src=&s_sale_branch_prim_dsp=-+%ED%8C%90%EB%A7%A4%EC%A0%90&s_sale_id=&state=8&state_obc=rgb(255%2C+255%2C+255)&state_otc=rgb(0%2C+0%2C+0)&state_src=&state_dsp=%E2%96%B6%EB%B0%9C%EC%86%A1&open_state=&open_state_obc=%23fff&open_state_otc=%23000&open_state_src=&open_state_dsp=-+%EA%B0%9C%ED%86%B5%EC%83%81%ED%83%9C&pre_model_return=&pre_model_return_obc=%23fff&pre_model_return_otc=%23000&pre_model_return_src=&pre_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%EA%B5%AC%EB%B6%84&excel_ext=csv&conf_self=&conf_self_obc=%23fff&conf_self_otc=%23000&conf_self_src=&conf_self_dsp=-+2%EC%B0%A8%EC%A7%84%ED%96%89%EC%83%81%ED%83%9C&new_model_return=&new_model_return_obc=%23fff&new_model_return_otc=%23000&new_model_return_src=&new_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%ED%98%84%ED%99%A9&post_size=500&data_orderby=a.reg_date&clm=0&search_word=&new_model=&new_model_src=&new_model_dsp=-+1%EC%B0%A8+%EC%83%81%ED%92%88&use_date_1=a.reg_date&start_date_1=${searchDate.start}&end_date_1=${searchDate.end}&age_sch_1=1&age_1=&age_cdn_1=1&age_cdn_join=1&age_sch_2=1&age_2=&age_cdn_2=1&ac_clm=0&ac_sbp=&sale_name_clm_q=eaaebfbf2fe3153006702ee0fda10b16&mode=search&page=${page}&hcv_p2=&list_type=&ol_type=logis&dv_prim=&team_prim=&tdm_prim=&prd_ds=&fav_group_prim=&no_ctm_rd_spd=&no_ctm_md_spd=&smr_vs=&no_sch_hl=&all_memo_sch_clm=&tbs_start_date=2022-10-05&tbs_end_date=2022-10-05&_ihr=n&_ihl=n&_content_only=y&site_gubun=pc
|
||||
|
||||
//블루맥스
|
||||
// s_customer_group=&s_customer_group_src=&s_customer_group_dsp=-+%EA%B3%A0%EA%B0%9D%EA%B7%B8%EB%A3%B9&s_open_branch_prim=&s_open_branch_prim_src=&s_open_branch_prim_dsp=-+%EA%B0%9C%ED%86%B5%EC%B2%98&s_sale_branch_prim=&s_sale_branch_prim_src=&s_sale_branch_prim_dsp=-+%ED%8C%90%EB%A7%A4%EC%A0%90&s_sale_id=&state=8&state_obc=rgb(255%2C+255%2C+255)&state_otc=rgb(0%2C+0%2C+0)&state_src=&state_dsp=%E2%96%B6%EB%B0%9C%EC%86%A1&open_state=&open_state_obc=%23fff&open_state_otc=%23000&open_state_src=&open_state_dsp=-+%EA%B0%9C%ED%86%B5%EC%83%81%ED%83%9C&pre_model_return=&pre_model_return_obc=%23fff&pre_model_return_otc=%23000&pre_model_return_src=&pre_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%EA%B5%AC%EB%B6%84&excel_ext=csv&conf_self=&conf_self_obc=%23fff&conf_self_otc=%23000&conf_self_src=&conf_self_dsp=-+2%EC%B0%A8%EC%A7%84%ED%96%89%EC%83%81%ED%83%9C&new_model_return=&new_model_return_obc=%23fff&new_model_return_otc=%23000&new_model_return_src=&new_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%ED%98%84%ED%99%A9&post_size=1000&data_orderby=a.reg_date&clm=15&search_word=블루맥스&new_model=&new_model_src=&new_model_dsp=-+1%EC%B0%A8+%EC%83%81%ED%92%88&use_date_1=a.reg_date&start_date_1=${searchDate.start}&end_date_1=${searchDate.end}&age_sch_1=1&age_1=&age_cdn_1=1&age_cdn_join=1&age_sch_2=1&age_2=&age_cdn_2=1&ac_clm=0&ac_sbp=&sale_name_clm_q=eaaebfbf2fe3153006702ee0fda10b16&mode=search&page=${page}&hcv_p2=&list_type=&ol_type=logis&dv_prim=&team_prim=&tdm_prim=&prd_ds=&fav_group_prim=&no_ctm_rd_spd=&no_ctm_md_spd=&smr_vs=&no_sch_hl=&all_memo_sch_clm=&tbs_start_date=2026-04-23&tbs_end_date=2026-04-23&_ihr=n&_ihl=n&_content_only=y&site_gubun=pc
|
||||
|
||||
let testStr = `
|
||||
s_customer_group=&s_customer_group_src=&s_customer_group_dsp=-+%EA%B3%A0%EA%B0%9D%EA%B7%B8%EB%A3%B9&s_open_branch_prim=&s_open_branch_prim_src=&s_open_branch_prim_dsp=-+%EA%B0%9C%ED%86%B5%EC%B2%98&s_sale_branch_prim=&s_sale_branch_prim_src=&s_sale_branch_prim_dsp=-+%ED%8C%90%EB%A7%A4%EC%A0%90&s_sale_id=&state=8&state_obc=rgb(255%2C+255%2C+255)&state_otc=rgb(0%2C+0%2C+0)&state_src=&state_dsp=%E2%96%B6%EB%B0%9C%EC%86%A1&open_state=&open_state_obc=%23fff&open_state_otc=%23000&open_state_src=&open_state_dsp=-+%EA%B0%9C%ED%86%B5%EC%83%81%ED%83%9C&pre_model_return=&pre_model_return_obc=%23fff&pre_model_return_otc=%23000&pre_model_return_src=&pre_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%EA%B5%AC%EB%B6%84&excel_ext=csv&conf_self=&conf_self_obc=%23fff&conf_self_otc=%23000&conf_self_src=&conf_self_dsp=-+2%EC%B0%A8%EC%A7%84%ED%96%89%EC%83%81%ED%83%9C&new_model_return=&new_model_return_obc=%23fff&new_model_return_otc=%23000&new_model_return_src=&new_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%ED%98%84%ED%99%A9&post_size=1000&data_orderby=a.reg_date&clm=0&search_word=&new_model=&new_model_src=&new_model_dsp=-+1%EC%B0%A8+%EC%83%81%ED%92%88&use_date_1=a.reg_date&start_date_1=${searchDate.start}&end_date_1=${searchDate.end}&age_sch_1=1&age_1=&age_cdn_1=1&age_cdn_join=1&age_sch_2=1&age_2=&age_cdn_2=1&ac_clm=0&ac_sbp=&sale_name_clm_q=eaaebfbf2fe3153006702ee0fda10b16&mode=search&page=${page}&hcv_p2=&list_type=&ol_type=logis&dv_prim=&team_prim=&tdm_prim=&prd_ds=&fav_group_prim=&no_ctm_rd_spd=&no_ctm_md_spd=&smr_vs=&no_sch_hl=&all_memo_sch_clm=&tbs_start_date=2022-10-05&tbs_end_date=2022-10-05&_ihr=n&_ihl=n&_content_only=y&site_gubun=pc
|
||||
`;
|
||||
try {
|
||||
} catch (error) {}
|
||||
|
||||
return axios
|
||||
.post(
|
||||
// 'http://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&svc_gubun=0&prd_ds=&dss=',
|
||||
`https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=240`,
|
||||
// qs.stringify(reqObj),
|
||||
testStr,
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// 'Host': 'hyun.bizmax.net',
|
||||
// 'Origin': 'https://hyun.bizmax.net',
|
||||
// 'Accept-Encoding': 'gzip, deflate',
|
||||
// 'Accept-Language':
|
||||
// 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
// 'Cache-Control': 'no-cache',
|
||||
// 'Connection': 'keep-alive',
|
||||
// 'Content-Length': '96',
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
// 'Host': 'hyun.bizmax.net',
|
||||
// 'Origin': 'https://hyun.bizmax.net',
|
||||
// 'Pragma': 'no-cache',
|
||||
// 'Referer':
|
||||
// 'https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=',
|
||||
// 'User-Agent':
|
||||
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
|
||||
// 'X-BizMax-Ajax': '1',
|
||||
// 'x-pvsn': 'V1',
|
||||
// 'X-Requested-With': 'XMLHttpRequest',
|
||||
// 'X-Site-Gubun': 'pc',
|
||||
|
||||
accept: "*/*",
|
||||
"accept-language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
pragma: "no-cache",
|
||||
"sec-ch-ua":
|
||||
'"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-ch-ua-platform": '"Windows"',
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"x-bizmax-ajax": "1",
|
||||
"x-pvsn": "V1",
|
||||
"x-requested-with": "XMLHttpRequest",
|
||||
"x-site-gubun": "pc",
|
||||
cookie: cookie[0],
|
||||
|
||||
Referer:
|
||||
"https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=",
|
||||
"Referrer-Policy": "strict-origin-when-cross-origin",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async (response) => {
|
||||
try {
|
||||
let lists = parseLists(response);
|
||||
// console.log(lists)
|
||||
console.log(lists.length);
|
||||
// return false
|
||||
|
||||
return lists;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
function parseLists(response) {
|
||||
let $ = cheerio.load(response.data);
|
||||
let lists = $(".sort_tr");
|
||||
// console.log(lists)
|
||||
lists = _.map(lists, (list) => {
|
||||
let item = {
|
||||
name: _.get(list, "children[0].children[0].attribs.name"),
|
||||
uuid: _.get(list, "children[0].children[1].attribs.value"),
|
||||
receipt_dt: _.get(list, "children[1].children[0].data"),
|
||||
group: _.get(list, "children[2].children[0].data"),
|
||||
store: _.get(list, "children[3].children[0].data"),
|
||||
r_name: _.get(list, "children[4].children[0].data"),
|
||||
product: _.get(list, "children[5].children[0].data"),
|
||||
progStatus: _.get(list, "children[6].children[0].data"),
|
||||
openStatus: _.get(list, "children[7].children[0].data"),
|
||||
deliveryInfo: parseDelivery(
|
||||
_.get(list, "children[8].children[0].attribs.onclick")
|
||||
),
|
||||
deliveryStatus: _.get(list, "children[11].children[0].data"),
|
||||
};
|
||||
return item;
|
||||
});
|
||||
return lists;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkLogis(lists) {
|
||||
try {
|
||||
let i = 0;
|
||||
await Aigle.eachSeries(lists, async (order) => {
|
||||
try {
|
||||
// console.log('order in', order)
|
||||
order.deliveryInfo[1] = order.deliveryInfo[1].replace(/-/g, "");
|
||||
|
||||
// if (i % 30 === 0 || hanjinCookie.length == 0) {
|
||||
// await createCookie()
|
||||
// }
|
||||
// sleep(1000)
|
||||
i += 1;
|
||||
try {
|
||||
console.log(`${i} :`, order.deliveryInfo);
|
||||
if (_.get(order, "deliveryInfo")[0] == "CJ택배") {
|
||||
let check = await checkCJ(order);
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
"YYYY-MM-DD"
|
||||
);
|
||||
order.deliveryEnd = true;
|
||||
}
|
||||
}
|
||||
if (_.get(order, "deliveryInfo")[0] == "우체국택배") {
|
||||
let check = await checkPostOffice(order);
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
"YYYY-MM-DD"
|
||||
);
|
||||
order.deliveryEnd = true;
|
||||
}
|
||||
// sleep(1500)
|
||||
}
|
||||
if (_.get(order, "deliveryInfo")[0] == "한진택배") {
|
||||
// let check = await checkHanjin(order)
|
||||
let check = await checkNewHanjin(order);
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
"YYYY-MM-DD"
|
||||
);
|
||||
order.deliveryEnd = true;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("errorObject", order);
|
||||
console.log(error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
return lists;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
function parseDelivery(deliveryStr) {
|
||||
if (deliveryStr) {
|
||||
// return deliveryStr
|
||||
// .replace('logisTrace("', '')
|
||||
// .replace('")', '')
|
||||
// .split('", "')
|
||||
|
||||
return deliveryStr
|
||||
.split('");')[0]
|
||||
.replace('logisTrace("', "")
|
||||
.split('", "');
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkCJ(order) {
|
||||
let url = `https://www.doortodoor.co.kr/parcel/doortodoor.do?fsp_action=PARC_ACT_002&fsp_cmd=retrieveInvNoACT&invc_no=${order.deliveryInfo[1]}`;
|
||||
|
||||
try {
|
||||
let body = await axios.get(url);
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$(".cont:eq(1)")
|
||||
.children(".board_area")
|
||||
.find("table > tbody > tr:last-child > td:first-child")
|
||||
.text()
|
||||
);
|
||||
let endDate = "";
|
||||
if (status == "배달완료") {
|
||||
endDate = _.trim(
|
||||
$(".cont:eq(1)")
|
||||
.children(".board_area")
|
||||
.find("table > tbody > tr:last-child > td:nth-child(2)")
|
||||
.text()
|
||||
);
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function checkNewHanjin(order) {
|
||||
try {
|
||||
let url = `https://www.hanjinexpress.hanjin.net/customer/hddcw18.tracking?w_num=${order.deliveryInfo[1]}`;
|
||||
|
||||
let body = await axios.get(url, {
|
||||
responseType: "arraybuffer",
|
||||
responseEncoding: "binary",
|
||||
});
|
||||
body.data = iconv.decode(body.data, "EUC-KR");
|
||||
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$(".board-list-table")
|
||||
.eq(1)
|
||||
.find("tbody > tr:last-child > td:last-child")
|
||||
.text()
|
||||
);
|
||||
|
||||
let endDate = "";
|
||||
if (status.indexOf("배송완료 되었습니다") !== -1) {
|
||||
endDate = _.trim(
|
||||
$(".board-list-table")
|
||||
.eq(1)
|
||||
.find("tbody > tr:last-child > td:first-child")
|
||||
.text()
|
||||
);
|
||||
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
if (error.response.status === 403) {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function checkHanjin(order) {
|
||||
try {
|
||||
let url = `https://www.hanjin.co.kr/kor/CMS/DeliveryMgr/WaybillResult.do`;
|
||||
|
||||
let formData = {
|
||||
mCode: "MN038",
|
||||
wblnum: order.deliveryInfo[1],
|
||||
// 'wblnum': 420095497301,
|
||||
schLang: "KR",
|
||||
wblnumText: "",
|
||||
};
|
||||
|
||||
let body = await axios
|
||||
.post(url, qs.stringify(formData), {
|
||||
headers: {
|
||||
accept:
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"accept-encoding": "gzip, deflate, br",
|
||||
"accept-language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
cookie: hanjinCookie[0],
|
||||
origin: "https://www.hanjin.co.kr",
|
||||
pragma: "no-cache",
|
||||
referer:
|
||||
"https://www.hanjin.co.kr/kor/CMS/DeliveryMgr/WaybillSch.do?mCode=MN038",
|
||||
"sec-fetch-dest": "document",
|
||||
"sec-fetch-mode": "navigate",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"sec-fetch-user": "?1",
|
||||
"upgrade-insecure-requests": 1,
|
||||
"user-agent":
|
||||
"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36",
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
return response;
|
||||
});
|
||||
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$(".board-list-table")
|
||||
.eq(1)
|
||||
.find("tbody > tr:last-child > td:last-child")
|
||||
.text()
|
||||
);
|
||||
|
||||
let endDate = "";
|
||||
if (status.indexOf("배송완료 되었습니다") !== -1) {
|
||||
endDate = _.trim(
|
||||
$(".board-list-table")
|
||||
.eq(1)
|
||||
.find("tbody > tr:last-child > td:first-child")
|
||||
.text()
|
||||
);
|
||||
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
async function checkPostOffice(order) {
|
||||
let url = `https://service.epost.go.kr/trace.RetrieveDomRigiTraceList.comm?sid1=${order.deliveryInfo[1]}&displayHeader=N`;
|
||||
|
||||
try {
|
||||
let body = await axios.get(url);
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$("#processTable")
|
||||
.find("tbody")
|
||||
.children("tr")
|
||||
.last()
|
||||
.children("td")
|
||||
.last()
|
||||
.text()
|
||||
);
|
||||
let endDate = "";
|
||||
if (status.indexOf("배달완료") !== -1) {
|
||||
endDate = _.trim(
|
||||
$("#processTable")
|
||||
.find("tbody")
|
||||
.children("tr")
|
||||
.last()
|
||||
.children("td")
|
||||
.first()
|
||||
.text()
|
||||
);
|
||||
endDate = _.replace(endDate, new RegExp("\\.", "g"), "-");
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
async function hanJinTest() {
|
||||
try {
|
||||
await createCookie();
|
||||
let orderLists = [{ deliveryInfo: ["한진택배", "421714876844"] }];
|
||||
await startCheckLogis(orderLists, false);
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
async function startCron() {
|
||||
console.log("startCron");
|
||||
try {
|
||||
console.log(await setCookie());
|
||||
let orderLists = [];
|
||||
let hanjinLists = [];
|
||||
|
||||
// await Aigle.eachSeries([1], async (page) => {
|
||||
await Aigle.eachSeries([1, 2, 3, 4], async (page) => {
|
||||
let result = await getLists(page);
|
||||
orderLists = [...orderLists, ...result];
|
||||
});
|
||||
|
||||
console.log("orderLists count", orderLists.length);
|
||||
await fs.writeFile(
|
||||
`${__dirname}/orderLists.json`,
|
||||
JSON.stringify(orderLists, null, 2),
|
||||
"utf8"
|
||||
);
|
||||
// console.log("saved orderLists", `${__dirname}/orderLists.json`);
|
||||
|
||||
// console.log(orderLists)
|
||||
|
||||
orderLists = _.filter(orderLists, (order) => {
|
||||
return order.deliveryInfo !== undefined;
|
||||
});
|
||||
|
||||
hanjinLists = _.remove(orderLists, (order) => {
|
||||
// console.log(order)
|
||||
return _.get(order, "deliveryInfo")[0] == "한진택배";
|
||||
});
|
||||
if (orderLists.length > 0) {
|
||||
await startCheckLogis(orderLists, false);
|
||||
}
|
||||
if (hanjinLists.length > 0) {
|
||||
await createCookie();
|
||||
await startCheckLogis(hanjinLists, true);
|
||||
}
|
||||
|
||||
console.log("ttt");
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function startCheckLogis(procLists, loopDelay = undefined) {
|
||||
procLists = _.reverse(procLists);
|
||||
|
||||
let chunkLists = _.chunk(procLists, 100);
|
||||
|
||||
// console.log(chunkLists[0])
|
||||
// return false
|
||||
|
||||
console.log("배송대기 주문 갯수", procLists.length);
|
||||
console.log(chunkLists[0].length);
|
||||
await Aigle.eachSeries(chunkLists, async (lists) => {
|
||||
let checkLists = await checkLogis(lists);
|
||||
|
||||
// orderLists = _.take(orderLists, 5)
|
||||
// 배송 완료 리스트 추출
|
||||
let finishedLists = _.filter(checkLists, (o) => {
|
||||
return o.deliveryEnd == true;
|
||||
});
|
||||
// console.log(finishedLists)
|
||||
// return false
|
||||
// 배송 미완료 리스트 추출
|
||||
let unfinishedLists = _.filter(checkLists, (o) => {
|
||||
return o.deliveryEnd !== true;
|
||||
});
|
||||
|
||||
// 배송 완료 리스트가 있으면
|
||||
if (finishedLists.length > 0) {
|
||||
await beforeChangePopUp(finishedLists);
|
||||
}
|
||||
sleep(3000);
|
||||
if (loopDelay) {
|
||||
console.log("5분 대기중 ...");
|
||||
sleep(300000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function beforeChangePopUp(lists) {
|
||||
let defaultBody = {
|
||||
lz_ctm_lspl_uv: "",
|
||||
lz_md_lsmdpl: "",
|
||||
lz_ctm_lcspl: LZString.compressToEncodedURIComponent(
|
||||
lists
|
||||
.map((list) => {
|
||||
return list.name;
|
||||
})
|
||||
.join(",")
|
||||
),
|
||||
lz_ctm_lspl: "",
|
||||
ctm_lcsql: lists
|
||||
.map((list) => {
|
||||
return list.uuid;
|
||||
})
|
||||
.join(","),
|
||||
ps_y: 0,
|
||||
ps_x: 0,
|
||||
_ihr: "n",
|
||||
_ihl: "n",
|
||||
_content_only: "y",
|
||||
site_gubun: "pc",
|
||||
};
|
||||
|
||||
let reqObj = _.merge(defaultBody);
|
||||
|
||||
let popup = await axios
|
||||
.post(
|
||||
"https://hyun.bizmax.net/customer/tpl/customer_list_logis_work.php",
|
||||
qs.stringify(reqObj),
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: `https://hyun.bizmax.net/main/?${Date.now()}`,
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async (response) => {
|
||||
try {
|
||||
console.log(response);
|
||||
let request = await processChange(response, lists);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function processChange(response, lists) {
|
||||
let prims = {};
|
||||
_.map(lists, (o, idx) => {
|
||||
idx += 1;
|
||||
prims["prim_" + idx] = o.name;
|
||||
prims["logis_invoice_" + idx] = o.deliveryInfo[1];
|
||||
prims[`no_${o.name}`] = idx;
|
||||
});
|
||||
let parseObj = parsePop(response.data);
|
||||
let defaultHeader = {
|
||||
cllw_ncf_clm_logis_invoice: 1,
|
||||
cllw_ncf_clm_logis_2_invoice: 1,
|
||||
cllw_ncf_clm_logis_return_invoice: 1,
|
||||
cllw_ncf_clm_open_seq: 1,
|
||||
cllw_ncf_clm_open_number: 1,
|
||||
cllw_ncf_clm_usim_seq: 1,
|
||||
logis_state: "배달완료",
|
||||
list_cnt: lists.length,
|
||||
};
|
||||
|
||||
let reqObj = _.merge(defaultHeader, parseObj, prims);
|
||||
|
||||
if (WRITE_END_DATE) {
|
||||
// reqObj.logis_end_date = moment(new Date()).format('YYYY-MM-DD')
|
||||
reqObj.logis_end_date = END_DATE;
|
||||
}
|
||||
|
||||
let result = await axios.post(
|
||||
// 'http://hyun.bizmax.net/customer/mng_customer/customer_list_logis_work_pcs_if.php',
|
||||
// 'http://hyun.bizmax.net/customer/mng_customer/customer_list_logis_work_pcs_if.php',
|
||||
"https://hyun.bizmax.net/customer/mng_customer/ctm_list_logis_work_pcs_jr.php",
|
||||
qs.stringify(reqObj),
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: `https://hyun.bizmax.net/main/?${Date.now()}`,
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
function parsePop(html) {
|
||||
let $ = cheerio.load(html);
|
||||
|
||||
let result = {};
|
||||
result.list_cnt = parseInt($("input[name=list_cnt]").val());
|
||||
result.process_time = parseInt($("input[name=process_time]").val());
|
||||
result.cssi = $("input[name=cssi]").val();
|
||||
result.acsb = $("input[name=acsb]").val();
|
||||
result.state = 6;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// changeTest()
|
||||
// getLists()
|
||||
|
||||
async function run() {
|
||||
console.log("started ....");
|
||||
cron.schedule("1 0 * * *", () => {
|
||||
try {
|
||||
console.log("started Schedule");
|
||||
console.log("run");
|
||||
startCron();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
//run();
|
||||
try {
|
||||
startCron();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
713
cron.js.save
Normal file
713
cron.js.save
Normal file
@@ -0,0 +1,713 @@
|
||||
const axios = require("axios");
|
||||
const FormData = require("form-data");
|
||||
const qs = require("querystring");
|
||||
const cheerio = require("cheerio");
|
||||
const _ = require("lodash");
|
||||
const Aigle = require("aigle");
|
||||
const moment = require("moment");
|
||||
const sleep = require("atomic-sleep");
|
||||
const iconv = require("iconv-lite");
|
||||
const { delay } = require("lodash");
|
||||
const cron = require("node-cron");
|
||||
|
||||
Aigle.mixin(_);
|
||||
|
||||
// let test = {}
|
||||
// test.deliveryInfo = ['우체국택배', '7865401358906']
|
||||
// checkPostOffice(test)
|
||||
|
||||
// if (!process.argv[2]) {
|
||||
// console.log('사용방법')
|
||||
// console.log('node test.js 완료일자 start|check')
|
||||
// console.log(moment(new Date()).subtract(1, 'day').format('YYYY-MM-DD'))
|
||||
// return false
|
||||
// }
|
||||
|
||||
// if (!process.argv[3]) {
|
||||
// console.log('사용방법')
|
||||
// console.log('node test.js 완료일자 start|check')
|
||||
// return false
|
||||
// }
|
||||
|
||||
let data = {
|
||||
username: "aa509004",
|
||||
password: "daesik102049@@",
|
||||
};
|
||||
|
||||
const WRITE_END_DATE = true;
|
||||
const END_DATE = moment(new Date()).subtract(1, "day").format("YYYY-MM-DD");
|
||||
|
||||
// let loginForm = new FormData()
|
||||
// loginForm.append('app_name',"크롬(chrome)")
|
||||
// loginForm.append('from',"pc")
|
||||
// loginForm.append('nhoj',"home3470")
|
||||
// loginForm.append('mluap',"5aee9b59574a3b9666400f9ea3ee5b4b")
|
||||
|
||||
let loginObj = {
|
||||
app_name: "크롬(chrome)",
|
||||
from: "pc",
|
||||
nhoj: "aa509004",
|
||||
mluap: "5aee9b59574a3b9666400f9ea3ee5b4b",
|
||||
};
|
||||
|
||||
let cookie = [
|
||||
"ds_yn=y; save_id=aa509004; ccn172=84ed141356cb95148bac1afb88b5ddaa663fd58c36ffa2f5ea536285791c754bb938f93336c4c72ac18203fc2ce5bcb004baf34ab6953952a1cb4bbf7be5186f8340853bef8e73ef33bfbdba0d2ce833e5acf7fe074a6d3bb79aa47e4de0dd120ac8821e605e23838cc4d70f65aa4186ed66ee406e0c003514e8a7edb3a7a47f3e5fe9c9ea44467ed469ccfd3fc368da37267711de8f9571b504605793f4c11a32694799eebc8c456ecd7e631a854cbc5cb586ac65a9c1965b0f04fe477e6aec127d7ecb8a0397d811ed70064f5fa09c",
|
||||
"ds_yn=y; path=/; domain=hyun.bizmax.net; HttpOnly",
|
||||
];
|
||||
|
||||
let hanjinCookie = [];
|
||||
|
||||
async function createCookie() {
|
||||
await axios.get("https://www.hanjin.co.kr").then((response) => {
|
||||
console.log(response.headers["set-cookie"]);
|
||||
hanjinCookie = response.headers["set-cookie"];
|
||||
});
|
||||
}
|
||||
|
||||
let bodyFormData = new URLSearchParams();
|
||||
bodyFormData.set("form", JSON.stringify(loginObj));
|
||||
|
||||
function setCookie() {
|
||||
console.log('setCookie');
|
||||
let cookie =
|
||||
|
||||
return new Promise((resolve) => {
|
||||
axios
|
||||
.post(
|
||||
"https://hyun.bizmax.net/login_pcs_jr.php",
|
||||
qs.stringify(loginObj),
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Length": "96",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Cookie: "ds_yn=y; save_id=home3470",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: "https://hyun.bizmax.net/?from=&dmy=1614347086",
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
// console.log(response)
|
||||
cookie = response.headers["set-cookie"];
|
||||
resolve(response.headers["set-cookie"]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function getLists(page) {
|
||||
let searchDate = {
|
||||
start: moment(new Date()).subtract(1, "month").format("YYYY-MM-DD"),
|
||||
// start: moment(new Date()).subtract(6, 'day').format('YYYY-MM-DD'),
|
||||
end: moment(new Date()).subtract(2, "day").format("YYYY-MM-DD"),
|
||||
};
|
||||
console.log(searchDate);
|
||||
|
||||
let reqObj = {
|
||||
state: 8,
|
||||
_content_only: "y",
|
||||
_ihl: "n",
|
||||
_ihr: "n",
|
||||
clm: 0,
|
||||
use_date_1: "a.reg_date",
|
||||
data_orderby: "a.reg_date",
|
||||
start_date_1: searchDate.start,
|
||||
end_date_1: searchDate.end,
|
||||
excel_ext: "csv",
|
||||
mode: "search",
|
||||
page: page,
|
||||
post_size: 500,
|
||||
sale_name_clm_q: "4b40dd075943efaf446b15696ebec5e3",
|
||||
site_gubun: "pc",
|
||||
tbs_end_date: "2021-02-26",
|
||||
tbs_start_date: "2021-02-26",
|
||||
};
|
||||
|
||||
let testStr = `
|
||||
s_customer_group=&s_customer_group_src=&s_customer_group_dsp=-+%EA%B3%A0%EA%B0%9D%EA%B7%B8%EB%A3%B9&s_open_branch_prim=&s_open_branch_prim_src=&s_open_branch_prim_dsp=-+%EA%B0%9C%ED%86%B5%EC%B2%98&s_sale_branch_prim=&s_sale_branch_prim_src=&s_sale_branch_prim_dsp=-+%ED%8C%90%EB%A7%A4%EC%A0%90&s_sale_id=&state=8&state_obc=rgb(255%2C+255%2C+255)&state_otc=rgb(0%2C+0%2C+0)&state_src=&state_dsp=%E2%96%B6%EB%B0%9C%EC%86%A1&open_state=&open_state_obc=%23fff&open_state_otc=%23000&open_state_src=&open_state_dsp=-+%EA%B0%9C%ED%86%B5%EC%83%81%ED%83%9C&pre_model_return=&pre_model_return_obc=%23fff&pre_model_return_otc=%23000&pre_model_return_src=&pre_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%EA%B5%AC%EB%B6%84&excel_ext=csv&conf_self=&conf_self_obc=%23fff&conf_self_otc=%23000&conf_self_src=&conf_self_dsp=-+2%EC%B0%A8%EC%A7%84%ED%96%89%EC%83%81%ED%83%9C&new_model_return=&new_model_return_obc=%23fff&new_model_return_otc=%23000&new_model_return_src=&new_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%ED%98%84%ED%99%A9&post_size=500&data_orderby=a.reg_date&clm=0&search_word=&new_model=&new_model_src=&new_model_dsp=-+1%EC%B0%A8+%EC%83%81%ED%92%88&use_date_1=a.reg_date&start_date_1=${searchDate.start}&end_date_1=${searchDate.end}&age_sch_1=1&age_1=&age_cdn_1=1&age_cdn_join=1&age_sch_2=1&age_2=&age_cdn_2=1&ac_clm=0&ac_sbp=&sale_name_clm_q=eaaebfbf2fe3153006702ee0fda10b16&mode=search&page=${page}&hcv_p2=&list_type=&ol_type=logis&dv_prim=&team_prim=&tdm_prim=&prd_ds=&fav_group_prim=&no_ctm_rd_spd=&no_ctm_md_spd=&smr_vs=&no_sch_hl=&all_memo_sch_clm=&tbs_start_date=2022-10-05&tbs_end_date=2022-10-05&_ihr=n&_ihl=n&_content_only=y&site_gubun=pc
|
||||
`;
|
||||
try {
|
||||
} catch (error) {}
|
||||
|
||||
return axios
|
||||
.post(
|
||||
// 'http://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&svc_gubun=0&prd_ds=&dss=',
|
||||
`https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=`,
|
||||
// qs.stringify(reqObj),
|
||||
testStr,
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// 'Host': 'hyun.bizmax.net',
|
||||
// 'Origin': 'https://hyun.bizmax.net',
|
||||
// 'Accept-Encoding': 'gzip, deflate',
|
||||
// 'Accept-Language':
|
||||
// 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
// 'Cache-Control': 'no-cache',
|
||||
// 'Connection': 'keep-alive',
|
||||
// 'Content-Length': '96',
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
// 'Host': 'hyun.bizmax.net',
|
||||
// 'Origin': 'https://hyun.bizmax.net',
|
||||
// 'Pragma': 'no-cache',
|
||||
// 'Referer':
|
||||
// 'https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=',
|
||||
// 'User-Agent':
|
||||
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
|
||||
// 'X-BizMax-Ajax': '1',
|
||||
// 'x-pvsn': 'V1',
|
||||
// 'X-Requested-With': 'XMLHttpRequest',
|
||||
// 'X-Site-Gubun': 'pc',
|
||||
|
||||
accept: "*/*",
|
||||
"accept-language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
pragma: "no-cache",
|
||||
"sec-ch-ua":
|
||||
'"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-ch-ua-platform": '"Windows"',
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"x-bizmax-ajax": "1",
|
||||
"x-pvsn": "V1",
|
||||
"x-requested-with": "XMLHttpRequest",
|
||||
"x-site-gubun": "pc",
|
||||
cookie: cookie[0],
|
||||
|
||||
Referer:
|
||||
"https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=",
|
||||
"Referrer-Policy": "strict-origin-when-cross-origin",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async (response) => {
|
||||
try {
|
||||
let lists = parseLists(response);
|
||||
// console.log(lists)
|
||||
console.log(lists.length);
|
||||
// return false
|
||||
|
||||
return lists;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
function parseLists(response) {
|
||||
let $ = cheerio.load(response.data);
|
||||
let lists = $(".sort_tr");
|
||||
// console.log(lists)
|
||||
lists = _.map(lists, (list) => {
|
||||
let item = {
|
||||
name: _.get(list, "children[0].children[0].attribs.name"),
|
||||
uuid: _.get(list, "children[0].children[1].attribs.value"),
|
||||
receipt_dt: _.get(list, "children[1].children[0].data"),
|
||||
group: _.get(list, "children[2].children[0].data"),
|
||||
store: _.get(list, "children[3].children[0].data"),
|
||||
r_name: _.get(list, "children[4].children[0].data"),
|
||||
product: _.get(list, "children[5].children[0].data"),
|
||||
progStatus: _.get(list, "children[6].children[0].data"),
|
||||
openStatus: _.get(list, "children[7].children[0].data"),
|
||||
deliveryInfo: parseDelivery(
|
||||
_.get(list, "children[8].children[0].attribs.onclick")
|
||||
),
|
||||
deliveryStatus: _.get(list, "children[11].children[0].data"),
|
||||
};
|
||||
return item;
|
||||
});
|
||||
return lists;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkLogis(lists) {
|
||||
try {
|
||||
let i = 0;
|
||||
await Aigle.eachSeries(lists, async (order) => {
|
||||
try {
|
||||
// console.log('order in', order)
|
||||
order.deliveryInfo[1] = order.deliveryInfo[1].replace(/-/g, "");
|
||||
|
||||
// if (i % 30 === 0 || hanjinCookie.length == 0) {
|
||||
// await createCookie()
|
||||
// }
|
||||
// sleep(1000)
|
||||
i += 1;
|
||||
try {
|
||||
console.log(`${i} :`, order.deliveryInfo);
|
||||
if (_.get(order, "deliveryInfo")[0] == "CJ택배") {
|
||||
let check = await checkCJ(order);
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
"YYYY-MM-DD"
|
||||
);
|
||||
order.deliveryEnd = true;
|
||||
}
|
||||
}
|
||||
if (_.get(order, "deliveryInfo")[0] == "우체국택배") {
|
||||
let check = await checkPostOffice(order);
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
"YYYY-MM-DD"
|
||||
);
|
||||
order.deliveryEnd = true;
|
||||
}
|
||||
// sleep(1500)
|
||||
}
|
||||
if (_.get(order, "deliveryInfo")[0] == "한진택배") {
|
||||
// let check = await checkHanjin(order)
|
||||
let check = await checkNewHanjin(order);
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
"YYYY-MM-DD"
|
||||
);
|
||||
order.deliveryEnd = true;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("errorObject", order);
|
||||
console.log(error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
return lists;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
function parseDelivery(deliveryStr) {
|
||||
if (deliveryStr) {
|
||||
// return deliveryStr
|
||||
// .replace('logisTrace("', '')
|
||||
// .replace('")', '')
|
||||
// .split('", "')
|
||||
|
||||
return deliveryStr
|
||||
.split('");')[0]
|
||||
.replace('logisTrace("', "")
|
||||
.split('", "');
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkCJ(order) {
|
||||
let url = `https://www.doortodoor.co.kr/parcel/doortodoor.do?fsp_action=PARC_ACT_002&fsp_cmd=retrieveInvNoACT&invc_no=${order.deliveryInfo[1]}`;
|
||||
|
||||
try {
|
||||
let body = await axios.get(url);
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$(".cont:eq(1)")
|
||||
.children(".board_area")
|
||||
.find("table > tbody > tr:last-child > td:first-child")
|
||||
.text()
|
||||
);
|
||||
let endDate = "";
|
||||
if (status == "배달완료") {
|
||||
endDate = _.trim(
|
||||
$(".cont:eq(1)")
|
||||
.children(".board_area")
|
||||
.find("table > tbody > tr:last-child > td:nth-child(2)")
|
||||
.text()
|
||||
);
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function checkNewHanjin(order) {
|
||||
try {
|
||||
let url = `https://www.hanjinexpress.hanjin.net/customer/hddcw18.tracking?w_num=${order.deliveryInfo[1]}`;
|
||||
|
||||
let body = await axios.get(url, {
|
||||
responseType: "arraybuffer",
|
||||
responseEncoding: "binary",
|
||||
});
|
||||
body.data = iconv.decode(body.data, "EUC-KR");
|
||||
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$(".board-list-table")
|
||||
.eq(1)
|
||||
.find("tbody > tr:last-child > td:last-child")
|
||||
.text()
|
||||
);
|
||||
|
||||
let endDate = "";
|
||||
if (status.indexOf("배송완료 되었습니다") !== -1) {
|
||||
endDate = _.trim(
|
||||
$(".board-list-table")
|
||||
.eq(1)
|
||||
.find("tbody > tr:last-child > td:first-child")
|
||||
.text()
|
||||
);
|
||||
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
if (error.response.status === 403) {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function checkHanjin(order) {
|
||||
try {
|
||||
let url = `https://www.hanjin.co.kr/kor/CMS/DeliveryMgr/WaybillResult.do`;
|
||||
|
||||
let formData = {
|
||||
mCode: "MN038",
|
||||
wblnum: order.deliveryInfo[1],
|
||||
// 'wblnum': 420095497301,
|
||||
schLang: "KR",
|
||||
wblnumText: "",
|
||||
};
|
||||
|
||||
let body = await axios
|
||||
.post(url, qs.stringify(formData), {
|
||||
headers: {
|
||||
accept:
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"accept-encoding": "gzip, deflate, br",
|
||||
"accept-language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
cookie: hanjinCookie[0],
|
||||
origin: "https://www.hanjin.co.kr",
|
||||
pragma: "no-cache",
|
||||
referer:
|
||||
"https://www.hanjin.co.kr/kor/CMS/DeliveryMgr/WaybillSch.do?mCode=MN038",
|
||||
"sec-fetch-dest": "document",
|
||||
"sec-fetch-mode": "navigate",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"sec-fetch-user": "?1",
|
||||
"upgrade-insecure-requests": 1,
|
||||
"user-agent":
|
||||
"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36",
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
return response;
|
||||
});
|
||||
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$(".board-list-table")
|
||||
.eq(1)
|
||||
.find("tbody > tr:last-child > td:last-child")
|
||||
.text()
|
||||
);
|
||||
|
||||
let endDate = "";
|
||||
if (status.indexOf("배송완료 되었습니다") !== -1) {
|
||||
endDate = _.trim(
|
||||
$(".board-list-table")
|
||||
.eq(1)
|
||||
.find("tbody > tr:last-child > td:first-child")
|
||||
.text()
|
||||
);
|
||||
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
async function checkPostOffice(order) {
|
||||
let url = `https://service.epost.go.kr/trace.RetrieveDomRigiTraceList.comm?sid1=${order.deliveryInfo[1]}&displayHeader=N`;
|
||||
|
||||
try {
|
||||
let body = await axios.get(url);
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$("#processTable")
|
||||
.find("tbody")
|
||||
.children("tr")
|
||||
.last()
|
||||
.children("td")
|
||||
.last()
|
||||
.text()
|
||||
);
|
||||
let endDate = "";
|
||||
if (status.indexOf("배달완료") !== -1) {
|
||||
endDate = _.trim(
|
||||
$("#processTable")
|
||||
.find("tbody")
|
||||
.children("tr")
|
||||
.last()
|
||||
.children("td")
|
||||
.first()
|
||||
.text()
|
||||
);
|
||||
endDate = _.replace(endDate, new RegExp("\\.", "g"), "-");
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
async function hanJinTest() {
|
||||
try {
|
||||
await createCookie();
|
||||
let orderLists = [{ deliveryInfo: ["한진택배", "421714876844"] }];
|
||||
await startCheckLogis(orderLists, false);
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
async function startCron() {
|
||||
console.log('startCron');
|
||||
try {
|
||||
console.log(await setCookie());
|
||||
let orderLists = [];
|
||||
let hanjinLists = [];
|
||||
|
||||
await Aigle.eachSeries([1, 2, 3, 4, 5], async (page) => {
|
||||
let result = await getLists(page);
|
||||
orderLists = [...orderLists, ...result];
|
||||
});
|
||||
|
||||
console.log("orderLists count", orderLists.length);
|
||||
// console.log(orderLists)
|
||||
|
||||
orderLists = _.filter(orderLists, (order) => {
|
||||
return order.deliveryInfo !== undefined;
|
||||
});
|
||||
|
||||
hanjinLists = _.remove(orderLists, (order) => {
|
||||
// console.log(order)
|
||||
return _.get(order, "deliveryInfo")[0] == "한진택배";
|
||||
});
|
||||
if (orderLists.length > 0) {
|
||||
await startCheckLogis(orderLists, false);
|
||||
}
|
||||
if (hanjinLists.length > 0) {
|
||||
await createCookie();
|
||||
await startCheckLogis(hanjinLists, true);
|
||||
}
|
||||
|
||||
console.log("ttt");
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
console.log("started ....");
|
||||
cron.schedule("1 0 * * *", () => {
|
||||
try {
|
||||
console.log("started Schedule");
|
||||
console.log("run");
|
||||
startCron();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
//run();
|
||||
startCron();
|
||||
|
||||
async function startCheckLogis(procLists, loopDelay = undefined) {
|
||||
procLists = _.reverse(procLists);
|
||||
|
||||
let chunkLists = _.chunk(procLists, 100);
|
||||
|
||||
// console.log(chunkLists[0])
|
||||
// return false
|
||||
|
||||
console.log("배송대기 주문 갯수", procLists.length);
|
||||
console.log(chunkLists[0].length);
|
||||
await Aigle.eachSeries(chunkLists, async (lists) => {
|
||||
let checkLists = await checkLogis(lists);
|
||||
|
||||
// orderLists = _.take(orderLists, 5)
|
||||
let finishedLists = _.filter(checkLists, (o) => {
|
||||
return o.deliveryEnd == true;
|
||||
});
|
||||
// console.log(finishedLists)
|
||||
// return false
|
||||
let unfinishedLists = _.filter(checkLists, (o) => {
|
||||
return o.deliveryEnd !== true;
|
||||
});
|
||||
|
||||
if (finishedLists.length > 0) {
|
||||
await beforeChangePopUp(finishedLists);
|
||||
}
|
||||
sleep(3000);
|
||||
if (loopDelay) {
|
||||
console.log("5분 대기중 ...");
|
||||
sleep(300000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function beforeChangePopUp(lists) {
|
||||
let prims = {};
|
||||
_.map(lists, (o, idx) => {
|
||||
idx += 1;
|
||||
prims["prim_" + idx] = o.uuid;
|
||||
});
|
||||
|
||||
let defaultHeader = {
|
||||
list_cnt: 20,
|
||||
page: 1,
|
||||
bde_cnt: 0,
|
||||
bde_col_pos: 0,
|
||||
svc_gubun: 0,
|
||||
force_todo_cnt: 0,
|
||||
_ihr: "n",
|
||||
_ihl: "n",
|
||||
_content_only: "y",
|
||||
site_gubun: "pc",
|
||||
};
|
||||
|
||||
let reqObj = _.merge(defaultHeader, prims);
|
||||
|
||||
let popup = await axios
|
||||
.post(
|
||||
"https://hyun.bizmax.net/customer/tpl/customer_list_logis_work.php",
|
||||
qs.stringify(reqObj),
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: "https://hyun.bizmax.net/?from=&dmy=1614347086",
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async (response) => {
|
||||
try {
|
||||
console.log(response);
|
||||
let request = await processChange(response, lists);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function processChange(response, lists) {
|
||||
let prims = {};
|
||||
_.map(lists, (o, idx) => {
|
||||
idx += 1;
|
||||
prims["prim_" + idx] = o.name;
|
||||
prims["logis_invoice_" + idx] = o.deliveryInfo[1];
|
||||
});
|
||||
let parseObj = parsePop(response.data);
|
||||
let defaultHeader = {
|
||||
a_logis_invoice: "on",
|
||||
a_logis_2_invoice: "on",
|
||||
a_logis_return_invoice: "on",
|
||||
a_open_seq: "on",
|
||||
a_open_number: "on",
|
||||
a_usim_seq: "on",
|
||||
};
|
||||
|
||||
let reqObj = _.merge(defaultHeader, parseObj, prims);
|
||||
|
||||
if (WRITE_END_DATE) {
|
||||
// reqObj.logis_end_date = moment(new Date()).format('YYYY-MM-DD')
|
||||
reqObj.logis_end_date = END_DATE;
|
||||
}
|
||||
|
||||
let result = await axios.post(
|
||||
// 'http://hyun.bizmax.net/customer/mng_customer/customer_list_logis_work_pcs_if.php',
|
||||
// 'http://hyun.bizmax.net/customer/mng_customer/customer_list_logis_work_pcs_if.php',
|
||||
"https://hyun.bizmax.net/customer/mng_customer/ctm_list_logis_work_pcs_jr.php",
|
||||
qs.stringify(reqObj),
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: "https://hyun.bizmax.net/?from=&dmy=1614347086",
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
function parsePop(html) {
|
||||
let $ = cheerio.load(html);
|
||||
|
||||
let result = {};
|
||||
result.csl = $("input[name=csl]").val();
|
||||
result.list_cnt = parseInt($("input[name=list_cnt]").val());
|
||||
result.process_time = parseInt($("input[name=process_time]").val());
|
||||
result.state = 6;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// changeTest()
|
||||
// getLists()
|
||||
|
||||
579
newcron.js
Normal file
579
newcron.js
Normal file
@@ -0,0 +1,579 @@
|
||||
const axios = require("axios");
|
||||
const FormData = require("form-data");
|
||||
const qs = require("querystring");
|
||||
const cheerio = require("cheerio");
|
||||
const _ = require("lodash");
|
||||
const Aigle = require("aigle");
|
||||
const moment = require("moment");
|
||||
const sleep = require("atomic-sleep");
|
||||
const iconv = require("iconv-lite");
|
||||
const { delay } = require("lodash");
|
||||
const cron = require("node-cron");
|
||||
const LZString = require("lz-string");
|
||||
|
||||
Aigle.mixin(_);
|
||||
|
||||
// let test = {}
|
||||
// test.deliveryInfo = ['우체국택배', '7865401358906']
|
||||
// checkPostOffice(test)
|
||||
|
||||
// if (!process.argv[2]) {
|
||||
// console.log('사용방법')
|
||||
// console.log('node test.js 완료일자 start|check')
|
||||
// console.log(moment(new Date()).subtract(1, 'day').format('YYYY-MM-DD'))
|
||||
// return false
|
||||
// }
|
||||
|
||||
// if (!process.argv[3]) {
|
||||
// console.log('사용방법')
|
||||
// console.log('node test.js 완료일자 start|check')
|
||||
// return false
|
||||
// }
|
||||
|
||||
let data = {
|
||||
username: "aa509004",
|
||||
password: "daesik102049@@",
|
||||
};
|
||||
|
||||
const WRITE_END_DATE = true;
|
||||
const END_DATE = moment(new Date()).subtract(1, "day").format("YYYY-MM-DD");
|
||||
|
||||
// let loginForm = new FormData()
|
||||
// loginForm.append('app_name',"크롬(chrome)")
|
||||
// loginForm.append('from',"pc")
|
||||
// loginForm.append('nhoj',"home3470")
|
||||
// loginForm.append('mluap',"5aee9b59574a3b9666400f9ea3ee5b4b")
|
||||
|
||||
let loginObj = {
|
||||
app_name: "크롬(chrome)",
|
||||
from: "pc",
|
||||
nhoj: "aa509004",
|
||||
mluap: "5aee9b59574a3b9666400f9ea3ee5b4b",
|
||||
};
|
||||
|
||||
let cookie = [
|
||||
"ds_yn=y; save_id=aa509004; ccn172=84ed141356cb95148bac1afb88b5ddaa663fd58c36ffa2f5ea536285791c754bb938f93336c4c72ac18203fc2ce5bcb004baf34ab6953952a1cb4bbf7be5186f8340853bef8e73ef33bfbdba0d2ce833e5acf7fe074a6d3bb79aa47e4de0dd120ac8821e605e23838cc4d70f65aa4186ed66ee406e0c003514e8a7edb3a7a47f3e5fe9c9ea44467ed469ccfd3fc368da37267711de8f9571b504605793f4c11a32694799eebc8c456ecd7e631a854cbc5cb586ac65a9c1965b0f04fe477e6aec127d7ecb8a0397d811ed70064f5fa09c",
|
||||
"ds_yn=y; path=/; domain=hyun.bizmax.net; HttpOnly",
|
||||
];
|
||||
|
||||
let bodyFormData = new URLSearchParams();
|
||||
bodyFormData.set("form", JSON.stringify(loginObj));
|
||||
|
||||
function setCookie() {
|
||||
console.log('setCookie');
|
||||
return new Promise((resolve) => {
|
||||
axios
|
||||
.post(
|
||||
"https://hyun.bizmax.net/login_pcs_jr.php",
|
||||
qs.stringify(loginObj),
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Length": "96",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Cookie: "ds_yn=y; save_id=home3470",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: `https://hyun.bizmax.net/main/?${Date.now()}`,
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
// console.log(response)
|
||||
cookie = response.headers["set-cookie"];
|
||||
resolve(response.headers["set-cookie"]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function getLists(page) {
|
||||
let searchDate = {
|
||||
start: moment(new Date()).subtract(1, "month").format("YYYY-MM-DD"),
|
||||
// start: moment(new Date()).subtract(6, 'day').format('YYYY-MM-DD'),
|
||||
end: moment(new Date()).subtract(1, "day").format("YYYY-MM-DD"),
|
||||
};
|
||||
console.log(searchDate);
|
||||
|
||||
let reqObj = {
|
||||
state: 8,
|
||||
_content_only: "y",
|
||||
_ihl: "n",
|
||||
_ihr: "n",
|
||||
clm: 0,
|
||||
use_date_1: "a.reg_date",
|
||||
data_orderby: "a.reg_date",
|
||||
start_date_1: searchDate.start,
|
||||
end_date_1: searchDate.end,
|
||||
excel_ext: "csv",
|
||||
mode: "search",
|
||||
page: page,
|
||||
post_size: 500,
|
||||
sale_name_clm_q: "4b40dd075943efaf446b15696ebec5e3",
|
||||
site_gubun: "pc",
|
||||
tbs_end_date: "2021-02-26",
|
||||
tbs_start_date: "2021-02-26",
|
||||
};
|
||||
|
||||
let testStr = `
|
||||
s_customer_group=&s_customer_group_src=&s_customer_group_dsp=-+%EA%B3%A0%EA%B0%9D%EA%B7%B8%EB%A3%B9&s_open_branch_prim=&s_open_branch_prim_src=&s_open_branch_prim_dsp=-+%EA%B0%9C%ED%86%B5%EC%B2%98&s_sale_branch_prim=&s_sale_branch_prim_src=&s_sale_branch_prim_dsp=-+%ED%8C%90%EB%A7%A4%EC%A0%90&s_sale_id=&state=8&state_obc=rgb(255%2C+255%2C+255)&state_otc=rgb(0%2C+0%2C+0)&state_src=&state_dsp=%E2%96%B6%EB%B0%9C%EC%86%A1&open_state=&open_state_obc=%23fff&open_state_otc=%23000&open_state_src=&open_state_dsp=-+%EA%B0%9C%ED%86%B5%EC%83%81%ED%83%9C&pre_model_return=&pre_model_return_obc=%23fff&pre_model_return_otc=%23000&pre_model_return_src=&pre_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%EA%B5%AC%EB%B6%84&excel_ext=csv&conf_self=&conf_self_obc=%23fff&conf_self_otc=%23000&conf_self_src=&conf_self_dsp=-+2%EC%B0%A8%EC%A7%84%ED%96%89%EC%83%81%ED%83%9C&new_model_return=&new_model_return_obc=%23fff&new_model_return_otc=%23000&new_model_return_src=&new_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%ED%98%84%ED%99%A9&post_size=500&data_orderby=a.reg_date&clm=0&search_word=&new_model=&new_model_src=&new_model_dsp=-+1%EC%B0%A8+%EC%83%81%ED%92%88&use_date_1=a.reg_date&start_date_1=${searchDate.start}&end_date_1=${searchDate.end}&age_sch_1=1&age_1=&age_cdn_1=1&age_cdn_join=1&age_sch_2=1&age_2=&age_cdn_2=1&ac_clm=0&ac_sbp=&sale_name_clm_q=eaaebfbf2fe3153006702ee0fda10b16&mode=search&page=${page}&hcv_p2=&list_type=&ol_type=logis&dv_prim=&team_prim=&tdm_prim=&prd_ds=&fav_group_prim=&no_ctm_rd_spd=&no_ctm_md_spd=&smr_vs=&no_sch_hl=&all_memo_sch_clm=&tbs_start_date=2022-10-05&tbs_end_date=2022-10-05&_ihr=n&_ihl=n&_content_only=y&site_gubun=pc
|
||||
`;
|
||||
return axios
|
||||
.post(
|
||||
// 'http://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&svc_gubun=0&prd_ds=&dss=',
|
||||
`https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=`,
|
||||
// qs.stringify(reqObj),
|
||||
testStr,
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// 'Host': 'hyun.bizmax.net',
|
||||
// 'Origin': 'https://hyun.bizmax.net',
|
||||
// 'Accept-Encoding': 'gzip, deflate',
|
||||
// 'Accept-Language':
|
||||
// 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
// 'Cache-Control': 'no-cache',
|
||||
// 'Connection': 'keep-alive',
|
||||
// 'Content-Length': '96',
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
// 'Host': 'hyun.bizmax.net',
|
||||
// 'Origin': 'https://hyun.bizmax.net',
|
||||
// 'Pragma': 'no-cache',
|
||||
// 'Referer':
|
||||
// 'https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=',
|
||||
// 'User-Agent':
|
||||
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
|
||||
// 'X-BizMax-Ajax': '1',
|
||||
// 'x-pvsn': 'V1',
|
||||
// 'X-Requested-With': 'XMLHttpRequest',
|
||||
// 'X-Site-Gubun': 'pc',
|
||||
|
||||
accept: "*/*",
|
||||
"accept-language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
pragma: "no-cache",
|
||||
"sec-ch-ua":
|
||||
'"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-ch-ua-platform": '"Windows"',
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"x-bizmax-ajax": "1",
|
||||
"x-pvsn": "V1",
|
||||
"x-requested-with": "XMLHttpRequest",
|
||||
"x-site-gubun": "pc",
|
||||
cookie: cookie[0],
|
||||
|
||||
Referer:
|
||||
"https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=",
|
||||
"Referrer-Policy": "strict-origin-when-cross-origin",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async (response) => {
|
||||
try {
|
||||
let lists = parseLists(response);
|
||||
// console.log(lists)
|
||||
console.log(lists.length);
|
||||
// return false
|
||||
|
||||
return lists;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
function parseLists(response) {
|
||||
let $ = cheerio.load(response.data);
|
||||
let lists = $(".sort_tr");
|
||||
// console.log(lists)
|
||||
lists = _.map(lists, (list) => {
|
||||
let item = {
|
||||
ckctm: _.get(list, "children[0].children[1].attribs.ck_ctm_prim"),
|
||||
name: _.get(list, "children[0].children[0].attribs.name"),
|
||||
uuid: _.get(list, "children[0].children[1].attribs.value"),
|
||||
receipt_dt: _.get(list, "children[1].children[0].data"),
|
||||
group: _.get(list, "children[2].children[0].data"),
|
||||
store: _.get(list, "children[3].children[0].data"),
|
||||
r_name: _.get(list, "children[4].children[0].data"),
|
||||
product: _.get(list, "children[5].children[0].data"),
|
||||
progStatus: _.get(list, "children[6].children[0].data"),
|
||||
openStatus: _.get(list, "children[7].children[0].data"),
|
||||
deliveryInfo: parseDelivery(
|
||||
_.get(list, "children[8].children[0].attribs.onclick")
|
||||
),
|
||||
deliveryStatus: _.get(list, "children[11].children[0].data"),
|
||||
};
|
||||
return item;
|
||||
});
|
||||
return lists;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkLogis(lists) {
|
||||
try {
|
||||
let i = 0;
|
||||
await Aigle.eachSeries(lists, async (order) => {
|
||||
try {
|
||||
// console.log('order in', order)
|
||||
order.deliveryInfo[1] = order.deliveryInfo[1].replace(/-/g, "");
|
||||
|
||||
// if (i % 30 === 0 || hanjinCookie.length == 0) {
|
||||
// await createCookie()
|
||||
// }
|
||||
// sleep(1000)
|
||||
i += 1;
|
||||
try {
|
||||
console.log(`${i} :`, order.deliveryInfo);
|
||||
if (_.get(order, "deliveryInfo")[0] == "CJ택배") {
|
||||
let check = await checkCJ(order);
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
"YYYY-MM-DD"
|
||||
);
|
||||
order.deliveryEnd = true;
|
||||
}
|
||||
}
|
||||
if (_.get(order, "deliveryInfo")[0] == "우체국택배") {
|
||||
let check = await checkPostOffice(order);
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
"YYYY-MM-DD"
|
||||
);
|
||||
order.deliveryEnd = true;
|
||||
}
|
||||
// sleep(1500)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log("errorObject", order);
|
||||
console.log(error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
return lists;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
function parseDelivery(deliveryStr) {
|
||||
if (deliveryStr) {
|
||||
// return deliveryStr
|
||||
// .replace('logisTrace("', '')
|
||||
// .replace('")', '')
|
||||
// .split('", "')
|
||||
|
||||
return deliveryStr
|
||||
.split('");')[0]
|
||||
.replace('logisTrace("', "")
|
||||
.split('", "');
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkCJ(order) {
|
||||
let url = `https://www.doortodoor.co.kr/parcel/doortodoor.do?fsp_action=PARC_ACT_002&fsp_cmd=retrieveInvNoACT&invc_no=${order.deliveryInfo[1]}`;
|
||||
|
||||
try {
|
||||
let body = await axios.get(url);
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$(".cont:eq(1)")
|
||||
.children(".board_area")
|
||||
.find("table > tbody > tr:last-child > td:first-child")
|
||||
.text()
|
||||
);
|
||||
let endDate = "";
|
||||
if (status == "배달완료") {
|
||||
endDate = _.trim(
|
||||
$(".cont:eq(1)")
|
||||
.children(".board_area")
|
||||
.find("table > tbody > tr:last-child > td:nth-child(2)")
|
||||
.text()
|
||||
);
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function checkPostOffice(order) {
|
||||
let url = `https://service.epost.go.kr/trace.RetrieveDomRigiTraceList.comm?sid1=${order.deliveryInfo[1]}&displayHeader=N`;
|
||||
|
||||
try {
|
||||
let body = await axios.get(url);
|
||||
let $ = cheerio.load(body.data);
|
||||
let status = _.trim(
|
||||
$("#processTable")
|
||||
.find("tbody")
|
||||
.children("tr")
|
||||
.last()
|
||||
.children("td")
|
||||
.last()
|
||||
.text()
|
||||
);
|
||||
let endDate = "";
|
||||
if (status.indexOf("배달완료") !== -1) {
|
||||
endDate = _.trim(
|
||||
$("#processTable")
|
||||
.find("tbody")
|
||||
.children("tr")
|
||||
.last()
|
||||
.children("td")
|
||||
.first()
|
||||
.text()
|
||||
);
|
||||
endDate = _.replace(endDate, new RegExp("\\.", "g"), "-");
|
||||
return {
|
||||
endDate: endDate,
|
||||
};
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function startCron() {
|
||||
console.log('startCron');
|
||||
try {
|
||||
console.log(await setCookie());
|
||||
|
||||
await Aigle.eachSeries([1, 2, 3, 4, 5, 6, 7], async (page) => {
|
||||
let orderLists = await getLists(page);
|
||||
|
||||
|
||||
console.log("orderLists count", orderLists.length);
|
||||
// console.log(orderLists)
|
||||
|
||||
orderLists = _.filter(orderLists, (order) => {
|
||||
return order.deliveryInfo !== undefined;
|
||||
});
|
||||
|
||||
if (orderLists.length > 0) {
|
||||
await startCheckLogis(orderLists, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
console.log("ttt");
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function startCheckLogis(procLists, loopDelay = undefined) {
|
||||
procLists = _.reverse(procLists);
|
||||
|
||||
let chunkLists = _.chunk(procLists, 100);
|
||||
|
||||
console.log("배송대기 주문 갯수", procLists.length);
|
||||
console.log(chunkLists[0].length);
|
||||
await Aigle.eachSeries(chunkLists, async (lists) => {
|
||||
let checkLists = await checkLogis(lists);
|
||||
|
||||
// orderLists = _.take(orderLists, 5)
|
||||
// 배송 완료 리스트 추출
|
||||
let finishedLists = _.filter(checkLists, (o) => {
|
||||
return o.deliveryEnd == true;
|
||||
});
|
||||
// console.log(finishedLists)
|
||||
// return false
|
||||
// 배송 미완료 리스트 추출
|
||||
let unfinishedLists = _.filter(checkLists, (o) => {
|
||||
return o.deliveryEnd !== true;
|
||||
});
|
||||
|
||||
// 배송 완료 리스트가 있으면
|
||||
if (finishedLists.length > 0) {
|
||||
await beforeChangePopUp(finishedLists);
|
||||
}
|
||||
sleep(3000);
|
||||
if (loopDelay) {
|
||||
console.log("5분 대기중 ...");
|
||||
sleep(300000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function beforeChangePopUp(lists) {
|
||||
let prims = {};
|
||||
_.map(lists, (o, idx) => {
|
||||
idx += 1;
|
||||
prims["prim_" + idx] = o.uuid;
|
||||
});
|
||||
|
||||
let defaultHeader = {
|
||||
list_cnt: 20,
|
||||
page: 1,
|
||||
bde_cnt: 0,
|
||||
bde_col_pos: 0,
|
||||
svc_gubun: 0,
|
||||
force_todo_cnt: 0,
|
||||
_ihr: "n",
|
||||
_ihl: "n",
|
||||
_content_only: "y",
|
||||
site_gubun: "pc",
|
||||
};
|
||||
|
||||
let reqObj = _.merge(defaultHeader, prims);
|
||||
|
||||
let popup = await axios
|
||||
.post(
|
||||
"https://hyun.bizmax.net/customer/tpl/customer_list_logis_work.php",
|
||||
qs.stringify(reqObj),
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: `https://hyun.bizmax.net/main/?${Date.now()}`,
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async (response) => {
|
||||
try {
|
||||
console.log(response);
|
||||
let request = await processChange(response, lists);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function processChange(response, lists) {
|
||||
let prims = {};
|
||||
_.map(lists, (o, idx) => {
|
||||
idx += 1;
|
||||
prims["prim_" + idx] = o.name;
|
||||
prims["logis_invoice_" + idx] = o.deliveryInfo[1];
|
||||
prims[`no_${o.name}`] = idx
|
||||
});
|
||||
let parseObj = parsePop(response.data);
|
||||
let defaultHeader = {
|
||||
cllw_ncf_clm_logis_invoice: 1,
|
||||
cllw_ncf_clm_logis_2_invoice: 1,
|
||||
cllw_ncf_clm_logis_return_invoice: 1,
|
||||
cllw_ncf_clm_open_seq: 1,
|
||||
cllw_ncf_clm_open_number: 1,
|
||||
cllw_ncf_clm_usim_seq: 1,
|
||||
logis_state: "배달완료",
|
||||
list_cnt: lists.length,
|
||||
|
||||
};
|
||||
|
||||
let reqObj = _.merge(defaultHeader, parseObj, prims);
|
||||
|
||||
if (WRITE_END_DATE) {
|
||||
// reqObj.logis_end_date = moment(new Date()).format('YYYY-MM-DD')
|
||||
reqObj.logis_end_date = END_DATE;
|
||||
}
|
||||
|
||||
let result = await axios.post(
|
||||
// 'http://hyun.bizmax.net/customer/mng_customer/customer_list_logis_work_pcs_if.php',
|
||||
// 'http://hyun.bizmax.net/customer/mng_customer/customer_list_logis_work_pcs_if.php',
|
||||
"https://hyun.bizmax.net/customer/mng_customer/ctm_list_logis_work_pcs_jr.php",
|
||||
qs.stringify(reqObj),
|
||||
{
|
||||
headers: {
|
||||
Cookie: cookie[0],
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language":
|
||||
"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Host: "hyun.bizmax.net",
|
||||
Origin: "https://hyun.bizmax.net",
|
||||
Pragma: "no-cache",
|
||||
Referer: `https://hyun.bizmax.net/main/?${Date.now()}`,
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
|
||||
"X-BizMax-Ajax": 1,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Site-Gubun": "pc",
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
function parsePop(html) {
|
||||
let $ = cheerio.load(html);
|
||||
|
||||
let result = {};
|
||||
result.list_cnt = parseInt($("input[name=list_cnt]").val());
|
||||
result.process_time = parseInt($("input[name=process_time]").val());
|
||||
result.cssi = $("input[name=cssi]").val();
|
||||
result.acsb = $("input[name=acsb]").val();
|
||||
result.state = 6;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// changeTest()
|
||||
// getLists()
|
||||
|
||||
async function run() {
|
||||
console.log("started ....");
|
||||
cron.schedule("1 0 * * *", () => {
|
||||
try {
|
||||
console.log("started Schedule");
|
||||
console.log("run");
|
||||
startCron();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
//run();
|
||||
try {
|
||||
startCron();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
26684
orderLists.json
Normal file
26684
orderLists.json
Normal file
File diff suppressed because it is too large
Load Diff
458
package-lock.json
generated
Normal file
458
package-lock.json
generated
Normal file
@@ -0,0 +1,458 @@
|
||||
{
|
||||
"name": "daesik",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "daesik",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"aigle": "^1.14.1",
|
||||
"atomic-sleep": "^1.0.0",
|
||||
"axios": "^0.21.1",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"form-data": "^4.0.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"lodash": "^4.17.21",
|
||||
"lz-string": "^1.5.0",
|
||||
"moment": "^2.29.1",
|
||||
"node-cron": "^3.0.0",
|
||||
"qs": "^6.10.3",
|
||||
"querystring": "^0.2.1"
|
||||
}
|
||||
},
|
||||
"node_modules/aigle": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/aigle/-/aigle-1.14.1.tgz",
|
||||
"integrity": "sha512-bCmQ65CEebspmpbWFs6ab3S27TNyVH1b5MledX8KoiGxUhsJmPUUGpaoSijhwawNnq5Lt8jbcq7Z7gUAD0nuTw==",
|
||||
"dependencies": {
|
||||
"aigle-core": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/aigle-core": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/aigle-core/-/aigle-core-1.0.0.tgz",
|
||||
"integrity": "sha1-QGbg+aXGCZbYN37RlqIfoXtiUKs="
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
},
|
||||
"node_modules/atomic-sleep": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
|
||||
"integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.21.4",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
|
||||
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/boolbase": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||
},
|
||||
"node_modules/call-bind": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
|
||||
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.1",
|
||||
"get-intrinsic": "^1.0.2"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/cheerio": {
|
||||
"version": "1.0.0-rc.10",
|
||||
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.10.tgz",
|
||||
"integrity": "sha512-g0J0q/O6mW8z5zxQ3A8E8J1hUgp4SMOvEoW/x84OwyHKe/Zccz83PVT4y5Crcr530FV6NgmKI1qvGTKVl9XXVw==",
|
||||
"dependencies": {
|
||||
"cheerio-select": "^1.5.0",
|
||||
"dom-serializer": "^1.3.2",
|
||||
"domhandler": "^4.2.0",
|
||||
"htmlparser2": "^6.1.0",
|
||||
"parse5": "^6.0.1",
|
||||
"parse5-htmlparser2-tree-adapter": "^6.0.1",
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/cheeriojs/cheerio?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cheerio-select": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.5.0.tgz",
|
||||
"integrity": "sha512-qocaHPv5ypefh6YNxvnbABM07KMxExbtbfuJoIie3iZXX1ERwYmJcIiRrr9H05ucQP1k28dav8rpdDgjQd8drg==",
|
||||
"dependencies": {
|
||||
"css-select": "^4.1.3",
|
||||
"css-what": "^5.0.1",
|
||||
"domelementtype": "^2.2.0",
|
||||
"domhandler": "^4.2.0",
|
||||
"domutils": "^2.7.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/css-select": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-4.2.1.tgz",
|
||||
"integrity": "sha512-/aUslKhzkTNCQUB2qTX84lVmfia9NyjP3WpDGtj/WxhwBzWBYUV3DgUpurHTme8UTPcPlAD1DJ+b0nN/t50zDQ==",
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0",
|
||||
"css-what": "^5.1.0",
|
||||
"domhandler": "^4.3.0",
|
||||
"domutils": "^2.8.0",
|
||||
"nth-check": "^2.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/css-what": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/css-what/-/css-what-5.1.0.tgz",
|
||||
"integrity": "sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw==",
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dom-serializer": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
|
||||
"integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^4.2.0",
|
||||
"entities": "^2.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domelementtype": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz",
|
||||
"integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/domhandler": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz",
|
||||
"integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domhandler?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domutils": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz",
|
||||
"integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==",
|
||||
"dependencies": {
|
||||
"dom-serializer": "^1.0.1",
|
||||
"domelementtype": "^2.2.0",
|
||||
"domhandler": "^4.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz",
|
||||
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==",
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.14.9",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
||||
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
|
||||
"integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.3",
|
||||
"has-symbols": "^1.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
|
||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/htmlparser2": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz",
|
||||
"integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==",
|
||||
"funding": [
|
||||
"https://github.com/fb55/htmlparser2?sponsor=1",
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^4.0.0",
|
||||
"domutils": "^2.5.2",
|
||||
"entities": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"node_modules/lz-string": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
|
||||
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
|
||||
"bin": {
|
||||
"lz-string": "bin/bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.29.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
|
||||
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/moment-timezone": {
|
||||
"version": "0.5.34",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
|
||||
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
|
||||
"dependencies": {
|
||||
"moment": ">= 2.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/node-cron": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.0.tgz",
|
||||
"integrity": "sha512-DDwIvvuCwrNiaU7HEivFDULcaQualDv7KoNlB/UU1wPW0n1tDEmBJKhEIE6DlF2FuoOHcNbLJ8ITL2Iv/3AWmA==",
|
||||
"dependencies": {
|
||||
"moment-timezone": "^0.5.31"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nth-check": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.1.tgz",
|
||||
"integrity": "sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w==",
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/nth-check?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz",
|
||||
"integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/parse5": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
|
||||
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
|
||||
},
|
||||
"node_modules/parse5-htmlparser2-tree-adapter": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz",
|
||||
"integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==",
|
||||
"dependencies": {
|
||||
"parse5": "^6.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.10.3",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
|
||||
"integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/querystring": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz",
|
||||
"integrity": "sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==",
|
||||
"deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.",
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
}
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"node_modules/side-channel": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
|
||||
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.0",
|
||||
"get-intrinsic": "^1.0.2",
|
||||
"object-inspect": "^1.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
}
|
||||
}
|
||||
}
|
||||
26
package.json
Normal file
26
package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "daesik",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"aigle": "^1.14.1",
|
||||
"atomic-sleep": "^1.0.0",
|
||||
"axios": "^0.21.1",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"form-data": "^4.0.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"lodash": "^4.17.21",
|
||||
"lz-string": "^1.5.0",
|
||||
"moment": "^2.29.1",
|
||||
"node-cron": "^3.0.0",
|
||||
"qs": "^6.10.3",
|
||||
"querystring": "^0.2.1"
|
||||
}
|
||||
}
|
||||
695
test.js
Normal file
695
test.js
Normal file
@@ -0,0 +1,695 @@
|
||||
const axios = require('axios')
|
||||
const FormData = require('form-data')
|
||||
const qs = require('querystring')
|
||||
const cheerio = require('cheerio')
|
||||
const _ = require('lodash')
|
||||
const Aigle = require('aigle')
|
||||
const moment = require('moment')
|
||||
const sleep = require('atomic-sleep')
|
||||
const iconv = require('iconv-lite')
|
||||
const { delay } = require('lodash')
|
||||
|
||||
Aigle.mixin(_)
|
||||
|
||||
// let test = {}
|
||||
// test.deliveryInfo = ['우체국택배', '7865401358906']
|
||||
// checkPostOffice(test)
|
||||
|
||||
if (!process.argv[2]) {
|
||||
console.log('사용방법')
|
||||
console.log('node test.js 완료일자 start|check')
|
||||
console.log(moment(new Date()).subtract(1, 'day').format('YYYY-MM-DD'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (!process.argv[3]) {
|
||||
console.log('사용방법')
|
||||
console.log('node test.js 완료일자 start|check')
|
||||
return false
|
||||
}
|
||||
|
||||
let data = {
|
||||
username: 'aa509004',
|
||||
password: 'daesik102049@@',
|
||||
}
|
||||
|
||||
const WRITE_END_DATE = true
|
||||
const END_DATE = process.argv[2]
|
||||
|
||||
// let loginForm = new FormData()
|
||||
// loginForm.append('app_name',"크롬(chrome)")
|
||||
// loginForm.append('from',"pc")
|
||||
// loginForm.append('nhoj',"home3470")
|
||||
// loginForm.append('mluap',"5aee9b59574a3b9666400f9ea3ee5b4b")
|
||||
|
||||
let loginObj = {
|
||||
app_name: '크롬(chrome)',
|
||||
from: 'pc',
|
||||
nhoj: 'aa509004',
|
||||
mluap: '5aee9b59574a3b9666400f9ea3ee5b4b',
|
||||
}
|
||||
|
||||
let cookie = [
|
||||
'ds_yn=y; save_id=aa509004; ccn172=84ed141356cb95148bac1afb88b5ddaa663fd58c36ffa2f5ea536285791c754bb938f93336c4c72ac18203fc2ce5bcb004baf34ab6953952a1cb4bbf7be5186f8340853bef8e73ef33bfbdba0d2ce833e5acf7fe074a6d3bb79aa47e4de0dd120ac8821e605e23838cc4d70f65aa4186ed66ee406e0c003514e8a7edb3a7a47f3e5fe9c9ea44467ed469ccfd3fc368da37267711de8f9571b504605793f4c11a32694799eebc8c456ecd7e631a854cbc5cb586ac65a9c1965b0f04fe477e6aec127d7ecb8a0397d811ed70064f5fa09c',
|
||||
'ds_yn=y; path=/; domain=hyun.bizmax.net; HttpOnly',
|
||||
]
|
||||
|
||||
let hanjinCookie = []
|
||||
|
||||
async function createCookie() {
|
||||
await axios.get('https://www.hanjin.co.kr').then(response => {
|
||||
console.log(response.headers['set-cookie'])
|
||||
hanjinCookie = response.headers['set-cookie']
|
||||
})
|
||||
}
|
||||
|
||||
let bodyFormData = new URLSearchParams()
|
||||
bodyFormData.set('form', JSON.stringify(loginObj))
|
||||
|
||||
function setCookie() {
|
||||
return new Promise(resolve => {
|
||||
axios
|
||||
.post(
|
||||
'https://hyun.bizmax.net/login_pcs_jr.php',
|
||||
qs.stringify(loginObj),
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Host': 'hyun.bizmax.net',
|
||||
'Origin': 'https://hyun.bizmax.net',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language':
|
||||
'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Connection': 'keep-alive',
|
||||
'Content-Length': '96',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Cookie': 'ds_yn=y; save_id=home3470',
|
||||
'Host': 'hyun.bizmax.net',
|
||||
'Origin': 'https://hyun.bizmax.net',
|
||||
'Pragma': 'no-cache',
|
||||
'Referer': 'https://hyun.bizmax.net/?from=&dmy=1614347086',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
|
||||
'X-BizMax-Ajax': 1,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'X-Site-Gubun': 'pc',
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(response => {
|
||||
// console.log(response)
|
||||
cookie = response.headers['set-cookie']
|
||||
resolve(response.headers['set-cookie'])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function getLists(page) {
|
||||
let searchDate = {
|
||||
start: moment(new Date()).subtract(1, 'month').format('YYYY-MM-DD'),
|
||||
// start: moment(new Date()).subtract(6, 'day').format('YYYY-MM-DD'),
|
||||
end: moment(new Date()).subtract(2, 'day').format('YYYY-MM-DD'),
|
||||
}
|
||||
console.log(searchDate)
|
||||
|
||||
let reqObj = {
|
||||
'state': 8,
|
||||
'_content_only': 'y',
|
||||
'_ihl': 'n',
|
||||
'_ihr': 'n',
|
||||
'clm': 0,
|
||||
'use_date_1': 'a.reg_date',
|
||||
'data_orderby': 'a.reg_date',
|
||||
'start_date_1': searchDate.start,
|
||||
'end_date_1': searchDate.end,
|
||||
'excel_ext': 'csv',
|
||||
'mode': 'search',
|
||||
'page': page,
|
||||
'post_size': 500,
|
||||
'sale_name_clm_q': '4b40dd075943efaf446b15696ebec5e3',
|
||||
'site_gubun': 'pc',
|
||||
'tbs_end_date': '2021-02-26',
|
||||
'tbs_start_date': '2021-02-26',
|
||||
}
|
||||
|
||||
let testStr = `
|
||||
s_customer_group=&s_customer_group_src=&s_customer_group_dsp=-+%EA%B3%A0%EA%B0%9D%EA%B7%B8%EB%A3%B9&s_open_branch_prim=&s_open_branch_prim_src=&s_open_branch_prim_dsp=-+%EA%B0%9C%ED%86%B5%EC%B2%98&s_sale_branch_prim=&s_sale_branch_prim_src=&s_sale_branch_prim_dsp=-+%ED%8C%90%EB%A7%A4%EC%A0%90&s_sale_id=&state=8&state_obc=rgb(255%2C+255%2C+255)&state_otc=rgb(0%2C+0%2C+0)&state_src=&state_dsp=%E2%96%B6%EB%B0%9C%EC%86%A1&open_state=&open_state_obc=%23fff&open_state_otc=%23000&open_state_src=&open_state_dsp=-+%EA%B0%9C%ED%86%B5%EC%83%81%ED%83%9C&pre_model_return=&pre_model_return_obc=%23fff&pre_model_return_otc=%23000&pre_model_return_src=&pre_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%EA%B5%AC%EB%B6%84&excel_ext=csv&conf_self=&conf_self_obc=%23fff&conf_self_otc=%23000&conf_self_src=&conf_self_dsp=-+2%EC%B0%A8%EC%A7%84%ED%96%89%EC%83%81%ED%83%9C&new_model_return=&new_model_return_obc=%23fff&new_model_return_otc=%23000&new_model_return_src=&new_model_return_dsp=-+%EA%B2%B0%EC%A0%9C%ED%98%84%ED%99%A9&post_size=500&data_orderby=a.reg_date&clm=0&search_word=&new_model=&new_model_src=&new_model_dsp=-+1%EC%B0%A8+%EC%83%81%ED%92%88&use_date_1=a.reg_date&start_date_1=${searchDate.start}&end_date_1=${searchDate.end}&age_sch_1=1&age_1=&age_cdn_1=1&age_cdn_join=1&age_sch_2=1&age_2=&age_cdn_2=1&ac_clm=0&ac_sbp=&sale_name_clm_q=eaaebfbf2fe3153006702ee0fda10b16&mode=search&page=${page}&hcv_p2=&list_type=&ol_type=logis&dv_prim=&team_prim=&tdm_prim=&prd_ds=&fav_group_prim=&no_ctm_rd_spd=&no_ctm_md_spd=&smr_vs=&no_sch_hl=&all_memo_sch_clm=&tbs_start_date=2022-10-05&tbs_end_date=2022-10-05&_ihr=n&_ihl=n&_content_only=y&site_gubun=pc
|
||||
`
|
||||
try {
|
||||
} catch (error) {}
|
||||
|
||||
return axios
|
||||
.post(
|
||||
// 'http://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&svc_gubun=0&prd_ds=&dss=',
|
||||
`https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=`,
|
||||
// qs.stringify(reqObj),
|
||||
testStr,
|
||||
{
|
||||
headers: {
|
||||
'Cookie': cookie[0],
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// 'Host': 'hyun.bizmax.net',
|
||||
// 'Origin': 'https://hyun.bizmax.net',
|
||||
// 'Accept-Encoding': 'gzip, deflate',
|
||||
// 'Accept-Language':
|
||||
// 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
// 'Cache-Control': 'no-cache',
|
||||
// 'Connection': 'keep-alive',
|
||||
// 'Content-Length': '96',
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
// 'Host': 'hyun.bizmax.net',
|
||||
// 'Origin': 'https://hyun.bizmax.net',
|
||||
// 'Pragma': 'no-cache',
|
||||
// 'Referer':
|
||||
// 'https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=',
|
||||
// 'User-Agent':
|
||||
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
|
||||
// 'X-BizMax-Ajax': '1',
|
||||
// 'x-pvsn': 'V1',
|
||||
// 'X-Requested-With': 'XMLHttpRequest',
|
||||
// 'X-Site-Gubun': 'pc',
|
||||
|
||||
'accept': '*/*',
|
||||
'accept-language':
|
||||
'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
'cache-control': 'no-cache',
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'pragma': 'no-cache',
|
||||
'sec-ch-ua':
|
||||
'"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'x-bizmax-ajax': '1',
|
||||
'x-pvsn': 'V1',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
'x-site-gubun': 'pc',
|
||||
'cookie': cookie[0],
|
||||
|
||||
'Referer':
|
||||
'https://hyun.bizmax.net/customer/tpl/customer_list.php?list_type=&team_prim=&tdm_prim=&svc_gubun=0&prd_ds=&dss=&dv_prim=',
|
||||
'Referrer-Policy': 'strict-origin-when-cross-origin',
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async response => {
|
||||
try {
|
||||
let lists = parseLists(response)
|
||||
// console.log(lists)
|
||||
console.log(lists.length)
|
||||
// return false
|
||||
|
||||
return lists
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
|
||||
function parseLists(response) {
|
||||
let $ = cheerio.load(response.data)
|
||||
let lists = $('.sort_tr')
|
||||
// console.log(lists)
|
||||
lists = _.map(lists, list => {
|
||||
let item = {
|
||||
name: _.get(list, 'children[0].children[0].attribs.name'),
|
||||
uuid: _.get(list, 'children[0].children[1].attribs.value'),
|
||||
receipt_dt: _.get(list, 'children[1].children[0].data'),
|
||||
group: _.get(list, 'children[2].children[0].data'),
|
||||
store: _.get(list, 'children[3].children[0].data'),
|
||||
r_name: _.get(list, 'children[4].children[0].data'),
|
||||
product: _.get(list, 'children[5].children[0].data'),
|
||||
progStatus: _.get(list, 'children[6].children[0].data'),
|
||||
openStatus: _.get(list, 'children[7].children[0].data'),
|
||||
deliveryInfo: parseDelivery(
|
||||
_.get(list, 'children[8].children[0].attribs.onclick')
|
||||
),
|
||||
deliveryStatus: _.get(list, 'children[11].children[0].data'),
|
||||
}
|
||||
return item
|
||||
})
|
||||
return lists
|
||||
}
|
||||
}
|
||||
|
||||
async function checkLogis(lists) {
|
||||
try {
|
||||
let i = 0
|
||||
await Aigle.eachSeries(lists, async order => {
|
||||
try {
|
||||
// console.log('order in', order)
|
||||
order.deliveryInfo[1] = order.deliveryInfo[1].replace(/-/g, '')
|
||||
|
||||
// if (i % 30 === 0 || hanjinCookie.length == 0) {
|
||||
// await createCookie()
|
||||
// }
|
||||
// sleep(1000)
|
||||
i += 1
|
||||
try {
|
||||
console.log(`${i} :`, order.deliveryInfo)
|
||||
if (_.get(order, 'deliveryInfo')[0] == 'CJ택배') {
|
||||
let check = await checkCJ(order)
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
'YYYY-MM-DD'
|
||||
)
|
||||
order.deliveryEnd = true
|
||||
}
|
||||
}
|
||||
if (_.get(order, 'deliveryInfo')[0] == '우체국택배') {
|
||||
let check = await checkPostOffice(order)
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
'YYYY-MM-DD'
|
||||
)
|
||||
order.deliveryEnd = true
|
||||
}
|
||||
// sleep(1500)
|
||||
}
|
||||
if (_.get(order, 'deliveryInfo')[0] == '한진택배') {
|
||||
// let check = await checkHanjin(order)
|
||||
let check = await checkNewHanjin(order)
|
||||
if (check) {
|
||||
order.deliveryEndDate = moment(new Date(check.endDate)).format(
|
||||
'YYYY-MM-DD'
|
||||
)
|
||||
order.deliveryEnd = true
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('errorObject', order)
|
||||
console.log(error)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
return lists
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
function parseDelivery(deliveryStr) {
|
||||
if (deliveryStr) {
|
||||
// return deliveryStr
|
||||
// .replace('logisTrace("', '')
|
||||
// .replace('")', '')
|
||||
// .split('", "')
|
||||
|
||||
return deliveryStr.split('");')[0].replace('logisTrace("', '').split('", "')
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
async function checkCJ(order) {
|
||||
let url = `https://www.doortodoor.co.kr/parcel/doortodoor.do?fsp_action=PARC_ACT_002&fsp_cmd=retrieveInvNoACT&invc_no=${order.deliveryInfo[1]}`
|
||||
|
||||
try {
|
||||
let body = await axios.get(url)
|
||||
let $ = cheerio.load(body.data)
|
||||
let status = _.trim(
|
||||
$('.cont:eq(1)')
|
||||
.children('.board_area')
|
||||
.find('table > tbody > tr:last-child > td:first-child')
|
||||
.text()
|
||||
)
|
||||
let endDate = ''
|
||||
if (status == '배달완료') {
|
||||
endDate = _.trim(
|
||||
$('.cont:eq(1)')
|
||||
.children('.board_area')
|
||||
.find('table > tbody > tr:last-child > td:nth-child(2)')
|
||||
.text()
|
||||
)
|
||||
return {
|
||||
endDate: endDate,
|
||||
}
|
||||
}
|
||||
return false
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
async function checkNewHanjin(order) {
|
||||
try {
|
||||
let url = `https://www.hanjinexpress.hanjin.net/customer/hddcw18.tracking?w_num=${order.deliveryInfo[1]}`
|
||||
|
||||
let body = await axios.get(url, {
|
||||
responseType: 'arraybuffer',
|
||||
responseEncoding: 'binary',
|
||||
})
|
||||
body.data = iconv.decode(body.data, 'EUC-KR')
|
||||
|
||||
let $ = cheerio.load(body.data)
|
||||
let status = _.trim(
|
||||
$('.board-list-table')
|
||||
.eq(1)
|
||||
.find('tbody > tr:last-child > td:last-child')
|
||||
.text()
|
||||
)
|
||||
|
||||
let endDate = ''
|
||||
if (status.indexOf('배송완료 되었습니다') !== -1) {
|
||||
endDate = _.trim(
|
||||
$('.board-list-table')
|
||||
.eq(1)
|
||||
.find('tbody > tr:last-child > td:first-child')
|
||||
.text()
|
||||
)
|
||||
|
||||
return {
|
||||
endDate: endDate,
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
if (error.response.status === 403) {
|
||||
process.exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function checkHanjin(order) {
|
||||
try {
|
||||
let url = `https://www.hanjin.co.kr/kor/CMS/DeliveryMgr/WaybillResult.do`
|
||||
|
||||
let formData = {
|
||||
'mCode': 'MN038',
|
||||
'wblnum': order.deliveryInfo[1],
|
||||
// 'wblnum': 420095497301,
|
||||
'schLang': 'KR',
|
||||
'wblnumText': '',
|
||||
}
|
||||
|
||||
let body = await axios
|
||||
.post(url, qs.stringify(formData), {
|
||||
headers: {
|
||||
'accept':
|
||||
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language':
|
||||
'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
'cache-control': 'no-cache',
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'cookie': hanjinCookie[0],
|
||||
'origin': 'https://www.hanjin.co.kr',
|
||||
'pragma': 'no-cache',
|
||||
'referer':
|
||||
'https://www.hanjin.co.kr/kor/CMS/DeliveryMgr/WaybillSch.do?mCode=MN038',
|
||||
'sec-fetch-dest': 'document',
|
||||
'sec-fetch-mode': 'navigate',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'sec-fetch-user': '?1',
|
||||
'upgrade-insecure-requests': 1,
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36',
|
||||
},
|
||||
})
|
||||
.then(response => {
|
||||
return response
|
||||
})
|
||||
|
||||
let $ = cheerio.load(body.data)
|
||||
let status = _.trim(
|
||||
$('.board-list-table')
|
||||
.eq(1)
|
||||
.find('tbody > tr:last-child > td:last-child')
|
||||
.text()
|
||||
)
|
||||
|
||||
let endDate = ''
|
||||
if (status.indexOf('배송완료 되었습니다') !== -1) {
|
||||
endDate = _.trim(
|
||||
$('.board-list-table')
|
||||
.eq(1)
|
||||
.find('tbody > tr:last-child > td:first-child')
|
||||
.text()
|
||||
)
|
||||
|
||||
return {
|
||||
endDate: endDate,
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
async function checkPostOffice(order) {
|
||||
let url = `https://service.epost.go.kr/trace.RetrieveDomRigiTraceList.comm?sid1=${order.deliveryInfo[1]}&displayHeader=N`
|
||||
|
||||
try {
|
||||
let body = await axios.get(url)
|
||||
let $ = cheerio.load(body.data)
|
||||
let status = _.trim(
|
||||
$('#processTable').find('tbody > tr:last-child > td:last-child').text()
|
||||
)
|
||||
let endDate = ''
|
||||
if (status.indexOf('배달완료') !== -1) {
|
||||
endDate = _.trim(
|
||||
$('#processTable').find('tbody > tr:last-child > td:first-child').text()
|
||||
)
|
||||
endDate = _.replace(endDate, new RegExp('\\.', 'g'), '-')
|
||||
return {
|
||||
endDate: endDate,
|
||||
}
|
||||
}
|
||||
return false
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
async function hanJinTest() {
|
||||
try {
|
||||
await createCookie()
|
||||
let orderLists = [{ deliveryInfo: ['한진택배', '421714876844'] }]
|
||||
await startCheckLogis(orderLists, false)
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
try {
|
||||
//한진 테스트용
|
||||
// await hanJinTest()
|
||||
// return false
|
||||
console.log('run end')
|
||||
console.log(await setCookie())
|
||||
let orderLists = []
|
||||
let hanjinLists = []
|
||||
|
||||
await Aigle.eachSeries([1, 2, 3, 4, 5], async page => {
|
||||
let result = await getLists(page)
|
||||
orderLists = [...orderLists, ...result]
|
||||
|
||||
if (process.argv[3] == 'check') {
|
||||
if (result.length < 500) {
|
||||
console.log('총갯수:', orderLists.length)
|
||||
console.log('리스트 끝')
|
||||
process.exit(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
console.log('orderLists count', orderLists.length)
|
||||
// console.log(orderLists)
|
||||
// return false
|
||||
if (process.argv[3] == 'check') {
|
||||
console.log('check')
|
||||
return false
|
||||
}
|
||||
|
||||
orderLists = _.filter(orderLists, order => {
|
||||
return order.deliveryInfo !== undefined
|
||||
})
|
||||
|
||||
hanjinLists = _.remove(orderLists, order => {
|
||||
// console.log(order)
|
||||
return _.get(order, 'deliveryInfo')[0] == '한진택배'
|
||||
})
|
||||
if (orderLists.length > 0) {
|
||||
await startCheckLogis(orderLists, false)
|
||||
}
|
||||
if (hanjinLists.length > 0) {
|
||||
await createCookie()
|
||||
await startCheckLogis(hanjinLists, true)
|
||||
}
|
||||
|
||||
console.log('ttt')
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
})()
|
||||
|
||||
async function startCheckLogis(procLists, loopDelay = undefined) {
|
||||
procLists = _.reverse(procLists)
|
||||
|
||||
let chunkLists = _.chunk(procLists, 100)
|
||||
|
||||
// console.log(chunkLists[0])
|
||||
// return false
|
||||
|
||||
console.log('배송대기 주문 갯수', procLists.length)
|
||||
console.log(chunkLists[0].length)
|
||||
await Aigle.eachSeries(chunkLists, async lists => {
|
||||
let checkLists = await checkLogis(lists)
|
||||
|
||||
// orderLists = _.take(orderLists, 5)
|
||||
let finishedLists = _.filter(checkLists, o => {
|
||||
return o.deliveryEnd == true
|
||||
})
|
||||
// console.log(finishedLists)
|
||||
// return false
|
||||
let unfinishedLists = _.filter(checkLists, o => {
|
||||
return o.deliveryEnd !== true
|
||||
})
|
||||
|
||||
if (finishedLists.length > 0) {
|
||||
await beforeChangePopUp(finishedLists)
|
||||
}
|
||||
sleep(3000)
|
||||
if (loopDelay) {
|
||||
console.log('5분 대기중 ...')
|
||||
sleep(300000)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function beforeChangePopUp(lists) {
|
||||
let prims = {}
|
||||
_.map(lists, (o, idx) => {
|
||||
idx += 1
|
||||
prims['prim_' + idx] = o.uuid
|
||||
})
|
||||
|
||||
let defaultHeader = {
|
||||
'list_cnt': 20,
|
||||
'page': 1,
|
||||
'bde_cnt': 0,
|
||||
'bde_col_pos': 0,
|
||||
'svc_gubun': 0,
|
||||
'force_todo_cnt': 0,
|
||||
'_ihr': 'n',
|
||||
'_ihl': 'n',
|
||||
'_content_only': 'y',
|
||||
'site_gubun': 'pc',
|
||||
}
|
||||
|
||||
let reqObj = _.merge(defaultHeader, prims)
|
||||
|
||||
let popup = await axios
|
||||
.post(
|
||||
'https://hyun.bizmax.net/customer/tpl/customer_list_logis_work.php',
|
||||
qs.stringify(reqObj),
|
||||
{
|
||||
headers: {
|
||||
'Cookie': cookie[0],
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Host': 'hyun.bizmax.net',
|
||||
'Origin': 'https://hyun.bizmax.net',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language':
|
||||
'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Connection': 'keep-alive',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Host': 'hyun.bizmax.net',
|
||||
'Origin': 'https://hyun.bizmax.net',
|
||||
'Pragma': 'no-cache',
|
||||
'Referer': 'https://hyun.bizmax.net/?from=&dmy=1614347086',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
|
||||
'X-BizMax-Ajax': 1,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'X-Site-Gubun': 'pc',
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async response => {
|
||||
try {
|
||||
console.log(response)
|
||||
let request = await processChange(response, lists)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function processChange(response, lists) {
|
||||
let prims = {}
|
||||
_.map(lists, (o, idx) => {
|
||||
idx += 1
|
||||
prims['prim_' + idx] = o.name
|
||||
prims['logis_invoice_' + idx] = o.deliveryInfo[1]
|
||||
})
|
||||
let parseObj = parsePop(response.data)
|
||||
let defaultHeader = {
|
||||
'a_logis_invoice': 'on',
|
||||
'a_logis_2_invoice': 'on',
|
||||
'a_logis_return_invoice': 'on',
|
||||
'a_open_seq': 'on',
|
||||
'a_open_number': 'on',
|
||||
'a_usim_seq': 'on',
|
||||
}
|
||||
|
||||
let reqObj = _.merge(defaultHeader, parseObj, prims)
|
||||
|
||||
if (WRITE_END_DATE) {
|
||||
// reqObj.logis_end_date = moment(new Date()).format('YYYY-MM-DD')
|
||||
reqObj.logis_end_date = END_DATE
|
||||
}
|
||||
|
||||
let result = await axios.post(
|
||||
// 'http://hyun.bizmax.net/customer/mng_customer/customer_list_logis_work_pcs_if.php',
|
||||
// 'http://hyun.bizmax.net/customer/mng_customer/customer_list_logis_work_pcs_if.php',
|
||||
'https://hyun.bizmax.net/customer/mng_customer/ctm_list_logis_work_pcs_jr.php',
|
||||
qs.stringify(reqObj),
|
||||
{
|
||||
headers: {
|
||||
'Cookie': cookie[0],
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Host': 'hyun.bizmax.net',
|
||||
'Origin': 'https://hyun.bizmax.net',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language':
|
||||
'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,zh-CN;q=0.5,zh;q=0.4',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Connection': 'keep-alive',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Host': 'hyun.bizmax.net',
|
||||
'Origin': 'https://hyun.bizmax.net',
|
||||
'Pragma': 'no-cache',
|
||||
'Referer': 'https://hyun.bizmax.net/?from=&dmy=1614347086',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
|
||||
'X-BizMax-Ajax': 1,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'X-Site-Gubun': 'pc',
|
||||
},
|
||||
}
|
||||
)
|
||||
console.log(result)
|
||||
}
|
||||
function parsePop(html) {
|
||||
let $ = cheerio.load(html)
|
||||
|
||||
let result = {}
|
||||
result.csl = $('input[name=csl]').val()
|
||||
result.list_cnt = parseInt($('input[name=list_cnt]').val())
|
||||
result.process_time = parseInt($('input[name=process_time]').val())
|
||||
result.state = 6
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// changeTest()
|
||||
// getLists()
|
||||
|
||||
6
test.ts
Normal file
6
test.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import LZString from "lz-string";
|
||||
|
||||
const input = "9340039,9340035";
|
||||
|
||||
const out = LZString.compressToEncodedURIComponent(input);
|
||||
console.log(out);
|
||||
3246
송장번호사라짐1.txt
Normal file
3246
송장번호사라짐1.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user