add request fail exception
This commit is contained in:
parent
175522f96c
commit
59a234ab71
36
cgvAjax.js
36
cgvAjax.js
|
|
@ -149,7 +149,7 @@ class cgvGetter {
|
||||||
const generalSeatCnt = 2;
|
const generalSeatCnt = 2;
|
||||||
// const startTime = moment('2024-02-05');
|
// const startTime = moment('2024-02-05');
|
||||||
// const endTIme = moment('2024-02-12');
|
// const endTIme = moment('2024-02-12');
|
||||||
const tmRange = { start: '1100', end: '1800' };
|
const tmRange = { start: '1200', end: '1800' };
|
||||||
let targetYMD = null;
|
let targetYMD = null;
|
||||||
let targetSchedule = null;
|
let targetSchedule = null;
|
||||||
|
|
||||||
|
|
@ -161,10 +161,22 @@ class cgvGetter {
|
||||||
//==================================================
|
//==================================================
|
||||||
while (1) {
|
while (1) {
|
||||||
// 스케줄 데이터 요청
|
// 스케줄 데이터 요청
|
||||||
const { cookies, data: result } = await this.getResultData(mgCD, targetYMD); // 20035290 듄, 20035256 웡카
|
let cookies, result;
|
||||||
|
let attempts = 0;
|
||||||
|
while (attempts < 10) {
|
||||||
|
const response = await this.getResultData(mgCD, targetYMD);
|
||||||
|
if (response) {
|
||||||
|
({ cookies, data: result } = response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
attempts++;
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
}
|
||||||
|
if (!cookies && !result) {
|
||||||
|
await __ERROR__(`사유: 스케줄 추출 작업 에러 / 현재시간: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
// 예외 - 요청 성공 확인
|
|
||||||
if (result === null) throw new Error(`\t> Request failed`);
|
|
||||||
// 예외(실험적) - 응답 데이터 구조 확인
|
// 예외(실험적) - 응답 데이터 구조 확인
|
||||||
if (!result.hasOwnProperty('d')) throw new Error(`\t> Response lacks the expected "d" property`);
|
if (!result.hasOwnProperty('d')) throw new Error(`\t> Response lacks the expected "d" property`);
|
||||||
const gScheduleList = JSON.parse(result.d);
|
const gScheduleList = JSON.parse(result.d);
|
||||||
|
|
@ -288,7 +300,21 @@ class cgvGetter {
|
||||||
Origin: 'https://m.cgv.co.kr',
|
Origin: 'https://m.cgv.co.kr',
|
||||||
Cookie: COOKIE
|
Cookie: COOKIE
|
||||||
}
|
}
|
||||||
const { cookies: loginCookies } = await this._post(this.loginAspx, loginParam, loginHeaders);
|
let loginCookies;
|
||||||
|
let attempts = 0;
|
||||||
|
while (attempts < 10) {
|
||||||
|
const response = await this._post(this.loginAspx, loginParam, loginHeaders);
|
||||||
|
if (response) {
|
||||||
|
({ cookies: loginCookies } = response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
attempts++;
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
}
|
||||||
|
if (!loginCookies) {
|
||||||
|
await __ERROR__(`사유: 쿠키 추출 작업 에러 / 현재시간: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
|
||||||
|
return -1
|
||||||
|
}
|
||||||
/* ++++++++++++ 예외 추가 or 예외 자체를 요청과정에 합병 */
|
/* ++++++++++++ 예외 추가 or 예외 자체를 요청과정에 합병 */
|
||||||
|
|
||||||
// cookie list -> cookie string
|
// cookie list -> cookie string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue