autojs- 聯衆識別

/**
 * 聯衆圖像識別函數
 * @param {string} username 聯衆圖像識別賬號 
 * @param {string} password 聯衆圖像識別密碼
 * @param {object} img 識別圖片
 * 快手極速版
 */


if (!requestScreenCapture()) {
    toast("請求截圖失敗");
    exit();
}
captureScreen("/sdcard/1" + ".jpg");//截圖

var a = className("android.view.View").clickable(true).depth(13).findOne().parent().bounds()
var imgx = a.left
var imgy = a.top
var imgw = a.width()
var imgh = a.height()

var src = images.read("/sdcard/1.jpg");
var clip = images.clip(src,imgx, imgy, imgw, imgh);//裁剪滑塊區域圖片  
images.save(clip, "/sdcard/clip.png");

username = ""//聯衆賬號
password = ""//聯衆密碼
img = images.read("/sdcard/clip.png")//讀取本機圖片路徑

var x1 = getCode(username, password, img).data.res.split("|")[0].split(",")[0]
var x2 = getCode(username, password, img).data.res.split("|")[1].split(",")[0]
log(x1)
log(x2)///返回打碼結果

//獲取滑動座標
var h =className("android.view.View").clickable(true).depth(12).findOne().bounds().centerY();

//開始滑動
swipe(x1,h,x2+10,h,1000);

function getCode(username, password, img) {
    http.__okhttp__.setTimeout(3e4);
    var r = images.toBase64(img, format = "png"), i = device.release, c = device.model, s = device.buildId;
    try {
        var n = http.postJson("https://v2-api.jsdama.com/upload", {
            softwareId: 19017, //軟件ID
            softwareSecret: "", //祕鑰
            username: username,
            password: password,
            captchaData: r,
            captchaType: 1310,   //識別類型(整形),
            captchaMinLength: 0,
            captchaMaxLength: 0,
            workerTipsId: 0
        }, {
            headers: {
                "User-Agent": "Mozilla/5.0 (Linux; Android " + i + "; " + c + " Build/" + s + "; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 Mobile Safari/537.36",
            }
        });
    } catch (e) {
        return {
            code: "-1",
            msg: "網絡鏈接超時...",
            data: {}
        };
    }
    var d = n.body.json(), p = d.code, m = d.message;
    if ("10079009" == p) return {
        code: p,
        msg: m,
        data: {}
    };
    if ("10142006" == p) return {
        code: p,
        msg: m,
        data: {}
    };
    if ("10142004" == p) return {
        code: p,
        msg: m,
        data: {}
    };
    if ("10142005" == p) return {
        code: p,
        msg: m,
        data: {}
    };
    if ("10079006" == p) return {
        code: p,
        msg: m,
        data: {}
    };
    if ("0" == p) {
        return {
            code: p,
            msg: m,
            data: {
                res: d.data.recognition
            }
        };
    }
    return d;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章