|
@@ -132,6 +132,24 @@ const gExpertsRecommendHeaders = {
|
|
|
'token': gExpertsRecommendToken
|
|
'token': gExpertsRecommendToken
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+let g168MemberHost = `168member.1680383.com`;
|
|
|
|
|
+let g168LoginCallbackUrl = encodeURIComponent(`https://j8b.168auutz.com/v1/`);
|
|
|
|
|
+const g168MemberHeaders = {
|
|
|
|
|
+ 'Sec-Fetch-Dest': `empty`,
|
|
|
|
|
+ 'Connection': `keep-alive`,
|
|
|
|
|
+ 'Accept-Encoding': `gzip, deflate, br`,
|
|
|
|
|
+ 'Content-Type': `application/json;charset=utf-8`,
|
|
|
|
|
+ 'Sec-Fetch-Site': `same-origin`,
|
|
|
|
|
+ 'Origin': `https://${g168MemberHost}`,
|
|
|
|
|
+ 'User-Agent': gUserAgent,
|
|
|
|
|
+ 'Sec-Fetch-Mode': `cors`,
|
|
|
|
|
+ 'Cookie': `2a29530a2306=57415995059943d0b7aaa457afde402447f42073204a91dc; JSESSIONID=EBF070671FFD978427A31DA1D6B79211`,
|
|
|
|
|
+ 'Host': `${g168MemberHost}`,
|
|
|
|
|
+ 'Referer': `https://${g168MemberHost}/login?callbackUrl=${g168LoginCallbackUrl}`,
|
|
|
|
|
+ 'Accept-Language': `zh-CN,zh-Hans;q=0.9`,
|
|
|
|
|
+ 'Accept': `application/json, text/plain, */*`
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const formatNow = () => {
|
|
const formatNow = () => {
|
|
|
return magicJS.formatDate(new Date(), 'yyyy-MM-dd');
|
|
return magicJS.formatDate(new Date(), 'yyyy-MM-dd');
|
|
|
}
|
|
}
|
|
@@ -384,6 +402,88 @@ async function getHtmlContent(url, headers) {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function check168UserLogin() {
|
|
|
|
|
+ let htmlUrl = `https://${g168MemberHost}/login?callbackUrl=${g168LoginCallbackUrl}`
|
|
|
|
|
+ let htmlContent = await getHtmlContent(htmlUrl, g168MemberHeaders);
|
|
|
|
|
+ let base64ImgData = await get168LoginCaptchaImage();
|
|
|
|
|
+ if (!base64ImgData) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ let recognizeRet = await tryAutoRecognizeCaptcha('ddddocr', { image: base64ImgData }, 'alphanum');
|
|
|
|
|
+ if (!recognizeRet) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ let codeStr = recognizeRet.code_data;
|
|
|
|
|
+ let loginRet = await do168UserLogin('aiyo21', 'aiyo510520', String(codeStr));
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function get168LoginCaptchaImage() {
|
|
|
|
|
+ let options = {
|
|
|
|
|
+ url: `https://${g168MemberHost}/captcha`,
|
|
|
|
|
+ headers: g168MemberHeaders,
|
|
|
|
|
+ body: ``,
|
|
|
|
|
+ };
|
|
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const imageData = base64encodeBytes(response.bodyBytes);
|
|
|
|
|
+ return imageData;
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ magicJS.logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ const msg = `请求验证码图片异常\n${JSON.stringify(err)}`;
|
|
|
|
|
+ magicJS.logger.error(msg);
|
|
|
|
|
+ });
|
|
|
|
|
+ return result;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function base64encodeBytes(bytes) {
|
|
|
|
|
+ let CryptoJS = createCryptoJS();
|
|
|
|
|
+ let data = CryptoJS.lib.WordArray.create(bytes);
|
|
|
|
|
+ let base64Data = CryptoJS.enc.Base64.stringify(data);
|
|
|
|
|
+ return base64Data;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function do168UserLogin(userName, password, captchaCode) {
|
|
|
|
|
+ let reqData = {
|
|
|
|
|
+ userName: userName,
|
|
|
|
|
+ password: password,
|
|
|
|
|
+ confirmPassword: password,
|
|
|
|
|
+ name: "",
|
|
|
|
|
+ mobile: "",
|
|
|
|
|
+ mobileCaptcha: "",
|
|
|
|
|
+ captcha: captchaCode,
|
|
|
|
|
+ loginType: ""
|
|
|
|
|
+ };
|
|
|
|
|
+ let options = {
|
|
|
|
|
+ url: `https://168member.1680383.com/userLogin`,
|
|
|
|
|
+ headers: g168MemberHeaders,
|
|
|
|
|
+ body: JSON.stringify(reqData),
|
|
|
|
|
+ };
|
|
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const body = response.body;
|
|
|
|
|
+ let rspData = null;
|
|
|
|
|
+ if (typeof body === "string") {
|
|
|
|
|
+ return {
|
|
|
|
|
+ code: -1,
|
|
|
|
|
+ message: "Response Exception"
|
|
|
|
|
+ };
|
|
|
|
|
+ } else if (typeof body === "object") {
|
|
|
|
|
+ rspData = body;
|
|
|
|
|
+ }
|
|
|
|
|
+ magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
|
|
+ return rspData;
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ magicJS.logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ const msg = `请求登陆验证异常\n${JSON.stringify(err)}`;
|
|
|
|
|
+ magicJS.logger.error(msg);
|
|
|
|
|
+ });
|
|
|
|
|
+ return result;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function checkTimeSlotPlanBuy() {
|
|
async function checkTimeSlotPlanBuy() {
|
|
|
// let htmlUrl = `https://${gBuyPlanHost}/v1/html/buy_plan/buy_plan.html`;
|
|
// let htmlUrl = `https://${gBuyPlanHost}/v1/html/buy_plan/buy_plan.html`;
|
|
|
// let htmlContent = await getHtmlContent(htmlUrl, gBuyPlanHeaders);
|
|
// let htmlContent = await getHtmlContent(htmlUrl, gBuyPlanHeaders);
|
|
@@ -1526,7 +1626,7 @@ async function tryGenerateCaptchaAndRecognize(tryCount = 1) {
|
|
|
if (!captchaRet || captchaRet.statusCode != 200) {
|
|
if (!captchaRet || captchaRet.statusCode != 200) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- recognizeRet = await tryAutoRecognizeCaptcha('ddddocr', captchaRet.result);
|
|
|
|
|
|
|
+ recognizeRet = await tryAutoRecognizeCaptcha('ddddocr', captchaRet.result, 'slide');
|
|
|
if (!recognizeRet) {
|
|
if (!recognizeRet) {
|
|
|
continue;
|
|
continue;
|
|
|
} else {
|
|
} else {
|
|
@@ -1567,24 +1667,32 @@ async function doGenerateCaptcha() {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function tryAutoRecognizeCaptcha(typeStr, captchaInfo) {
|
|
|
|
|
|
|
+async function tryAutoRecognizeCaptcha(typeStr, captchaInfo, recognizeType) {
|
|
|
switch (typeStr) {
|
|
switch (typeStr) {
|
|
|
case 'ddddocr':
|
|
case 'ddddocr':
|
|
|
- return recognizeCaptchaByDdddocr(captchaInfo);
|
|
|
|
|
|
|
+ return recognizeCaptchaByDdddocr(captchaInfo, recognizeType);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function recognizeCaptchaByDdddocr(captchaInfo) {
|
|
|
|
|
- let puzzleImage = captchaInfo.puzzleImage;
|
|
|
|
|
- let backgroundImage = captchaInfo.backgroundImage;
|
|
|
|
|
- let positionY = captchaInfo.positionY;
|
|
|
|
|
- let uuid = captchaInfo.uuid;
|
|
|
|
|
- let reqData = {
|
|
|
|
|
- recognize_type: 'slide',
|
|
|
|
|
- puzzle_image: encodeURIComponent(puzzleImage),
|
|
|
|
|
- background_image: encodeURIComponent(backgroundImage),
|
|
|
|
|
- position_y: positionY,
|
|
|
|
|
- uuid: uuid,
|
|
|
|
|
|
|
+async function recognizeCaptchaByDdddocr(captchaInfo, recognizeType) {
|
|
|
|
|
+ // recognizeType: alphanum slide cn_boxes
|
|
|
|
|
+ let reqData = null;
|
|
|
|
|
+ if (recognizeType == 'slide') {
|
|
|
|
|
+ let puzzleImage = captchaInfo.puzzleImage;
|
|
|
|
|
+ let backgroundImage = captchaInfo.backgroundImage;
|
|
|
|
|
+ let positionY = captchaInfo.positionY;
|
|
|
|
|
+ let uuid = captchaInfo.uuid;
|
|
|
|
|
+ reqData = {
|
|
|
|
|
+ recognize_type: recognizeType,
|
|
|
|
|
+ puzzle_image: encodeURIComponent(puzzleImage),
|
|
|
|
|
+ background_image: encodeURIComponent(backgroundImage),
|
|
|
|
|
+ position_y: positionY,
|
|
|
|
|
+ uuid: uuid,
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (recognizeType == 'alphanum') {
|
|
|
|
|
+ reqData = captchaInfo;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ reqData = captchaInfo;
|
|
|
}
|
|
}
|
|
|
let form = magicJS.objToQueryStr(reqData);
|
|
let form = magicJS.objToQueryStr(reqData);
|
|
|
let headers = {
|
|
let headers = {
|
|
@@ -1623,20 +1731,21 @@ async function recognizeCaptchaByDdddocr(captchaInfo) {
|
|
|
magicJS.logger.error(msg);
|
|
magicJS.logger.error(msg);
|
|
|
});
|
|
});
|
|
|
if (result && result.code == 1) {
|
|
if (result && result.code == 1) {
|
|
|
- let targetInfo = result.result.target;
|
|
|
|
|
- if (Math.abs(targetInfo[1] - positionY) > 4) {
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ if (recognizeType == 'slide') {
|
|
|
|
|
+ let targetInfo = result.result.target;
|
|
|
|
|
+ if (Math.abs(targetInfo[1] - positionY) > 4) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.positionX = targetInfo[0] + randomFloat(0, 0.5);
|
|
|
|
|
+ result.positionY = reqData.position_y;
|
|
|
|
|
+ result.uuid = reqData.uuid;
|
|
|
|
|
+ } else {
|
|
|
}
|
|
}
|
|
|
- result.positionX = targetInfo[0] + randomFloat(0, 0.5);
|
|
|
|
|
- result.positionY = positionY;
|
|
|
|
|
- result.uuid = uuid;
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
function randomFloat(min, max) {
|
|
function randomFloat(min, max) {
|
|
|
return Math.random() * (max - min) + min;
|
|
return Math.random() * (max - min) + min;
|
|
|
}
|
|
}
|