qq(q音乐)扫码授权登陆分析及python实现

详细的代码后期会放到github上,后面补上链接,敬请期待。

⬇️ ⬇️  ⬇️  ⬇️  ⬇️  ⬇️

源码来啦,带搜索及下载歌曲,点我点我

⬆️ ⬆️ ⬆️ ⬆️ ⬆️

一,获取QQ音乐登陆二维码

1,打开扫码的登陆界面,将javascript context设置为pt_login_iframe

2.该条url为返回登陆二维码的请求,debug找出发送该请求的js及具体位置

具体获取地址的js片段:

...
setTimeout(function() {
                try {
                    (0,
                    k["default"])("qrlogin_img").src = S.get_qrlogin_pic()
                } catch (t) {
                    S.qrloginGetTime = 0
                }
            }, 0)
...

3. js中搜索get_qrlogin_pic()

"__get_polling_url": function(t) {
            t = (C.ptui.isHttps ? "https://ssl." : "http://") + "ptlogin2." + C.ptui.domain + "/" + t + "?";
            return t += "appid=" + C.ptui.appid + "&e=2&l=M&s=3&d=72&v=4&t=" + Math.random(),
            C.ptui.regmaster && (t += "&regmaster=" + C.ptui.regmaster),
            C.ptui.daid && (t += "&daid=" + C.ptui.daid),
            S.isTim && (t += "&tim=1"),
            C.ptui.pt_3rd_aid && (t += "&pt_3rd_aid=" + C.ptui.pt_3rd_aid),
            t
        },
        "get_qrlogin_pic": function() {
            return S.__get_polling_url("ptqrshow")
        },

由js可以看出变量C中有我们所需的关键数据

这里博主饶了些小弯路,在js及network中都不能找到初始化或者赋值变量C的请求

在js中可以看出C(PT)是直接挂载到windo对象下的

最后在html中搜索关键字才找到初始化的位置

js如下:

!function () {
    window.onerror = function (n, e, o) {
        var t = document.createElement("img"),
            _ = encodeURIComponent(n + "|_|" + e + "|_|" + o + "|_|" + window.navigator.userAgent);
        t.src = "//ui.ptlogin2.qq.com/cgi-bin/report?id=195279&msg=" + _ + "&v=" + Math.random()
    }
}();
var g_cdn_js_fail = !1, pt = {};
pt.str = {
    no_uin: "你还没有输入帐号!",
    no_pwd: "你还没有输入密码!",
    no_vcode: "你还没有输入验证码!",
    inv_uin: "请输入正确的帐号!",
    inv_vcode: "请输入完整的验证码!",
    qlogin_expire: "你所选择号码对应的QQ已经失效,请检查该号码对应的QQ是否已经被关闭。",
    other_login: "帐号登录",
    h_pt_login: "帐号密码登录",
    otherqq_login: "QQ帐号密码登录",
    onekey_return: "返回扫码登录"
}, pt.ptui = {
    s_url: "https\x3A\x2F\x2Fgraph.qq.com\x2Foauth2.0\x2Flogin_jump",
    proxy_url: "",
    jumpname: encodeURIComponent(""),
    mibao_css: encodeURIComponent(""),
    defaultUin: "",
    lockuin: parseInt("0"),
    href: "https\x3A\x2F\x2Fxui.ptlogin2.qq.com\x2Fcgi-bin\x2Fxlogin\x3Fappid\x3D716027609\x26daid\x3D383\x26style\x3D33\x26theme\x3D2\x26login_text\x3D\x25E6\x258E\x2588\x25E6\x259D\x2583\x25E5\x25B9\x25B6\x25E7\x2599\x25BB\x25E5\x25BD\x2595\x26hide_title_bar\x3D1\x26hide_border\x3D1\x26target\x3Dself\x26s_url\x3Dhttps\x253A\x252F\x252Fgraph.qq.com\x252Foauth2.0\x252Flogin_jump\x26pt_3rd_aid\x3D100497308\x26pt_feedback_link\x3Dhttps\x253A\x252F\x252Fsupport.qq.com\x252Fproducts\x252F77942\x253FcustomInfo\x253D.appid100497308",
    login_sig: "",
    clientip: "",
    serverip: "",
    version: "202101062347",
    ptui_version: encodeURIComponent("21010623"),
    isHttps: !1,
    cssPath: "https://ui.ptlogin2.qq.com/style.ssl/40",
    domain: encodeURIComponent("qq.com"),
    fromStyle: parseInt(""),
    pt_3rd_aid: encodeURIComponent("100497308"),
    appid: encodeURIComponent("716027609"),
    lang: encodeURIComponent("2052"),
    style: encodeURIComponent("40"),
    low_login: encodeURIComponent("0"),
    daid: encodeURIComponent("383"),
    regmaster: encodeURIComponent(""),
    enable_qlogin: "1",
    noAuth: "0",
    target: isNaN(parseInt("0")) ? {_top: 1, _self: 0, _parent: 2}["0"] : parseInt("0"),
    csimc: encodeURIComponent("0"),
    csnum: encodeURIComponent("0"),
    authid: encodeURIComponent("0"),
    auth_mode: encodeURIComponent("0"),
    pt_qzone_sig: "0",
    pt_light: "0",
    pt_vcode_v1: "1",
    pt_ver_md5: "000D64FF6AF2E4247B21E209EB22A1DBCF002087B988CCCCD4B51233",
    gzipEnable: "1"
}; 

现在数据就一目了然了

博主在这里偷懒直接讲原始的js拷贝过来然后利用execjs工具来加载并获取js中的方法或者数据

获取pt数据代码示例:

# 读取js
def load_js(name):
    f = open(name, 'r', encoding='utf-8')
    js_text = ''
    while True:
        readline = f.readline()
        if readline:
            js_text += readline
        else:
            break
    return js_text

# pt_js.js
def get_pt_js():
    return load_js('pt_data.js')

# 获取pt
def get_pt():
    # 加载js
    execjs_execjs = execjs.compile(get_pt_js())
    return execjs_execjs.call('getPt', None)

ps:在js中博主定义了getPt的方法

function getPt(){
    return pt;
}

4.获取二维码Python源码,其中判断逻辑使用了js的逻辑:

    # 获取跳转链接
    def _get_polling_url(self, str_p):
        c = self.pt
        t = 'https://ssl.' if c['ptui']['isHttps'] else 'http://'
        t = t + 'ptlogin2.' + c['ptui']['domain'] + '/' + str_p + '?'
        t += 'appid=' + c['ptui']['appid'] + '&e=2&l=M&s=3&d=72&v=4&t=' + str(random.random())
        if c['ptui']['daid']:
            t += '&daid=' + c['ptui']['daid']
            # if s.isTim:
            # t += '&tim=1'
        if c['ptui']['pt_3rd_aid']:
            t += '&pt_3rd_aid=' + c['ptui']['pt_3rd_aid']
        return t


    # 获取二维码登陆图片地址
    def get_qrlogin_pic(self):
        heads = {
        }
        url = self._get_polling_url('ptqrshow')
        response = self.session.get(url)
        util.save_img(response, "login_qr.png")

二,检测是否扫码并授权

在network中可以看到检测是否扫码授权的请求

一路查找

"getSubmitUrl": function(t) {
            var e, i, n = S.loginUrl + t + "?", o = {};
            if ("pt_susp_repush" == t)
                return n + ("appid=" + C.ptui.appid + "&daid=" + C.ptui.daid);
            for (i in "login" == t && (o.u = encodeURIComponent(S.at_account),
            o.verifycode = (0,
            k["default"])("verifycode").value,
            console.log("getSubmitUrl setParams verifycode", (0,
            k["default"])("verifycode").value),
            S.needShowNewVc ? o.pt_vcode_v1 = 1 : o.pt_vcode_v1 = 0,
            o.pt_verifysession_v1 = S.pt_verifysession || k["default"].cookie.get("verifysession"),
            e = (0,
            k["default"])("p").value,
            S.armSafeEdit.isSafe && (e = S.armSafeEdit.safepwd),
            o.p = r["default"].getEncryption(e, S.salt, o.verifycode, S.armSafeEdit.isSafe),
            o.pt_randsalt = S.isRandSalt || 0,
            window.TDC && window.TDC.getInfo && window.TDC.getInfo().tokenid && (o.pt_jstoken = window.TDC.getInfo().tokenid),
            console.log("getSubmitUrl loginName == login branch finished")),
            o.u1 = "login" == t ? encodeURIComponent(a["default"].getSurl((0,
            k["default"])("u").value)) : encodeURIComponent(a["default"].getSurl()),
            "ptqrlogin" == t && (o.ptqrtoken = k["default"].str.hash33(k["default"].cookie.get("qrsig"))),
            "pt_susp_poll" == t && (o.pt_susp_poll_token = k["default"].str.hash33(k["default"].cookie.get("pt_susp_sig"))),
            o.ptredirect = C.ptui.target,
            o.h = 1,
            o.t = 1,
            o.g = 1,
            o.from_ui = 1,
            o.ptlang = C.ptui.lang,
            o.action = S.action.join("-") + "-" + +new Date,
            o.js_ver = C.ptui.ptui_version,
            o.js_type = S.js_type,
            o.login_sig = C.ptui.login_sig,
            o.pt_uistyle = C.ptui.style,
            1 == C.ptui.low_login && S.low_login_enable && !S.isMailLogin && (o.low_login_enable = 1,
            o.low_login_hour = S.low_login_hour),
            "0" != C.ptui.csimc && (o.csimc = C.ptui.csimc,
            o.csnum = C.ptui.csnum,
            o.authid = C.ptui.authid),
            o.aid = C.ptui.appid,
            C.ptui.daid && (o.daid = C.ptui.daid),
            "0" != C.ptui.pt_3rd_aid && (o.pt_3rd_aid = C.ptui.pt_3rd_aid),
            C.ptui.regmaster && (o.regmaster = C.ptui.regmaster),
            C.ptui.mibao_css && (o.mibao_css = C.ptui.mibao_css),
            "1" == C.ptui.pt_qzone_sig && (o.pt_qzone_sig = 1),
            "1" == C.ptui.pt_light && (o.pt_light = 1),
            S.ptdrvs && (o.ptdrvs = S.ptdrvs),
            S.sessionID && (o.sid = S.sessionID),
            o)
                n += i + "=" + o[i] + "&";
            return S.isTim && (n += "tim=1&"),
            a["default"].hasOneKeyList() && (n += "has_onekey=1&"),
            a["default"].QQProtectGUID && (n += "&pt_guid_sig=" + a["default"].QQProtectGUID),
            n
        },

主要关注请求中带的几个参数

login_sig在上个请求会在cookie中返回 从cookie中可以查出

pt_login_sig = self.session.cookies.get('pt_login_sig')

还有ptqtoken参数,需要调用其他方法获取

实际上就是加密了下login_sig参数

"hash33": function(t) {
                for (var e = 0, i = 0, n = t.length; i < n; ++i)
                    e += (e << 5) + t.charCodeAt(i);
                return 2147483647 & e
            }

其他都是固定或者拼接的参数

检测是否扫码及认证代码:

def check(self):
        pt_login_sig = self.session.cookies.get('pt_login_sig')
        if pt_login_sig is None:
            pt_login_sig = self.pt['ptui']['login_sig']
        qrsig = self.session.cookies.get('qrsig')
        login_url = 'https://ssl.' if self.pt['ptui']['isHttps'] else 'http://'
        login_url += 'ptlogin2.' + self.pt['ptui']['domain'] + '/'
        t = 'ptqrlogin'
        login_url += t + '?'
        login_url += 'u1=' + parse.quote(self.pt['ptui']['s_url'], safe='')
        login_url += '&ptqrtoken=' + str(util.get_ptqrtoken(qrsig))
        login_url += '&ptredirect=' + str(self.pt['ptui']['target'])
        login_url += '&h=1&t=1&g=1&from_ui=1'
        login_url += '&ptlang=' + self.pt['ptui']['lang']
        login_url += '&action=0-0-' + str(int(time.time()))
        login_url += '&js_ver=' + self.pt['ptui']['ptui_version']
        login_url += '&js_type=1'
        login_url += '&login_sig=' + pt_login_sig
        login_url += '&pt_uistyle=' + self.pt['ptui']['style']
        login_url += '&aid=' + self.pt['ptui']['appid']
        login_url += '&daid=' + self.pt['ptui']['daid']
        login_url += '&pt_3rd_aid=' + self.pt['ptui']['pt_3rd_aid']
        resp = self.session.get(login_url)
        return resp

当扫码登陆后,响应体会返回若干cookie

接下来到认证阶段:

请求认证成功后会302跳转,该请求请求参数来源js:

python构造请求:

    def authorize(self):
        c = RequestsCookieJar()
        ui = util.guid()
        c.set('ui', ui, path='/', domain='graph.qq.co')
        self.session.cookies.update(c)

        cgi_url = 'https://graph.qq.com/oauth2.0/authorize'

        headers = {
            'User-Agent': util.get_user_agents(),
            'Referer': 'https://graph.qq.com/oauth2.0/show?which=Login&display=pc&response_type=code&client_id=100497308&redirect_uri=https%3A%2F%2Fy.qq.com%2Fportal%2Fwx_redirect.html%3Flogin_type%3D1%26surl%3Dhttps%253A%252F%252Fy.qq.com%252Fportal%252Fprofile.html%2523stat%253Dy_new.top.user_pic%2526stat%253Dy_new.top.pop.logout%26use_customer_cb%3D0&state=state&display=pc',
            'Content-Type': 'application/x-www-form-urlencoded',
        }

        payload = {
            'response_type': 'code',
            'client_id': '100497308',
            'redirect_uri': 'https://y.qq.com/portal/wx_redirect.html?login_type=1&surl=https%3A%2F%2Fy.qq.com%2F%23&use_customer_cb=0',
            'scope': '',
            'state': 'state',
            'switch': '',
            'from_ptlogin': '1',
            'src': '1',
            'update_auth': '1',
            'openapi': '80901010',
            'g_tk': util.get_g_tk(self.session.cookies.get('p_skey')),
            'auth_time': str(int(time.time())),
            'ui': ui
        }
        urlencode = parse.urlencode(payload)
        post = self.session.post(cgi_url, headers=headers, data=urlencode)
        return post

请求包含一个生成uuid的js方法

同样简单copy js方法修改用execjs调用

function guid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    }).toUpperCase();
};

getToken,获取cookies中的p_skey值进行处理

  /**
   * 获取g_tk
   */
  Q.getToken = function() {
    var str = Q.getCookie('p_skey') || '',
      hash = 5381;
    for (var i = 0, len = str.length; i < len; ++i) {
      hash += (hash << 5) + str.charCodeAt(i);
    }
    return hash & 0x7fffffff;
  };

302跳转的页面中的js比较重要

 

 

主要作用发起以下请求

 

参数获取与上述请求无太大区别,在此就不一一分析

返回的cookie就可以用来在qq音乐中认证

 

python代码:

 # 获取认证的cookie
    def get_login_cookie(self, code):
        headers = {
            'User-Agent': util.get_user_agents(),
            'Referer': 'https://y.qq.com/',
            'Content-Type': 'application/x-www-form-urlencoded',
        }
        g_tk = util.get_g_tk(self.session.cookies.get('p_skey'));
        param = {
            "comm": {
                "g_tk": g_tk,
                "platform": "yqq",
                "ct": 24,
                "cv": 0
            },
            "token": {
                "module": "QQConnectLogin.LoginServer",
                "method": "QQLogin",
                "param": {
                    "code": code
                }
            }
        }
        response = self.session.post('https://u.y.qq.com/cgi-bin/musicu.fcg', headers=headers, data=json.dumps(param))
        return response

 

用采集到的cookie构造请求就可以成功验证请求

以下是请求一个接口验证是否成功登陆

 # 检测是否登录
    def check_login(self):
        data = {"comm":
                    {"ct": 24, "cv": 0},
                "getFavorList": {"method": "get_favor_list",
                                 "param":
                                     {"userid": self.spider_session.get_user_id(),
                                      "fav_type": 1},
                                 "module": "music.favor_system_read"}
                }
        dumps = json.dumps(data)
        payload = {
            'sign': util.get_sign(dumps),
            'data': dumps,
        }
        response = self.session.get('https://u.y.qq.com/cgi-bin/musics.fcg', params=payload)
        return response

ok,成功返回

ps:该接口get_sign方法原加密如下,有兴趣的可以自己深入钻研钻研:

QQ音乐API分析之-加密参数分析(sign计算)

推荐上面博文学习

水平有限,以上仅做总结和分享,请大佬勿喷,欢迎各位前来交流学习。



!function(n, t) {
    "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (n = n || self).getSecuritySign = t()
}(this, function() {
    "use strict";
    var n = function() {
        if ("undefined" != typeof self)
            return self;
        if ("undefined" != typeof window)
            return window;
        if ("undefined" != typeof global)
            return global;
        throw new Error("unable to locate global object")
    }();
    n.__sign_hash_20200305 = function(n) {
        function l(n, t) {
            var o = (65535 & n) + (65535 & t);
            return (n >> 16) + (t >> 16) + (o >> 16) << 16 | 65535 & o
        }
        function r(n, t, o, e, u, p) {
            return l((i = l(l(t, n), l(e, p))) << (r = u) | i >>> 32 - r, o);
            var i, r
        }
        function g(n, t, o, e, u, p, i) {
            return r(t & o | ~t & e, n, t, u, p, i)
        }
        function a(n, t, o, e, u, p, i) {
            return r(t & e | o & ~e, n, t, u, p, i)
        }
        function s(n, t, o, e, u, p, i) {
            return r(t ^ o ^ e, n, t, u, p, i)
        }
        function v(n, t, o, e, u, p, i) {
            return r(o ^ (t | ~e), n, t, u, p, i)
        }
        function t(n) {
            return function(n) {
                var t, o = "";
                for (t = 0; t < 32 * n.length; t += 8)
                    o += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
                return o
            }(function(n, t) {
                n[t >> 5] |= 128 << t % 32,
                    n[14 + (t + 64 >>> 9 << 4)] = t;
                var o, e, u, p, i, r = 1732584193, f = -271733879, h = -1732584194, c = 271733878;
                for (o = 0; o < n.length; o += 16)
                    r = g(e = r, u = f, p = h, i = c, n[o], 7, -680876936),
                        c = g(c, r, f, h, n[o + 1], 12, -389564586),
                        h = g(h, c, r, f, n[o + 2], 17, 606105819),
                        f = g(f, h, c, r, n[o + 3], 22, -1044525330),
                        r = g(r, f, h, c, n[o + 4], 7, -176418897),
                        c = g(c, r, f, h, n[o + 5], 12, 1200080426),
                        h = g(h, c, r, f, n[o + 6], 17, -1473231341),
                        f = g(f, h, c, r, n[o + 7], 22, -45705983),
                        r = g(r, f, h, c, n[o + 8], 7, 1770035416),
                        c = g(c, r, f, h, n[o + 9], 12, -1958414417),
                        h = g(h, c, r, f, n[o + 10], 17, -42063),
                        f = g(f, h, c, r, n[o + 11], 22, -1990404162),
                        r = g(r, f, h, c, n[o + 12], 7, 1804603682),
                        c = g(c, r, f, h, n[o + 13], 12, -40341101),
                        h = g(h, c, r, f, n[o + 14], 17, -1502002290),
                        r = a(r, f = g(f, h, c, r, n[o + 15], 22, 1236535329), h, c, n[o + 1], 5, -165796510),
                        c = a(c, r, f, h, n[o + 6], 9, -1069501632),
                        h = a(h, c, r, f, n[o + 11], 14, 643717713),
                        f = a(f, h, c, r, n[o], 20, -373897302),
                        r = a(r, f, h, c, n[o + 5], 5, -701558691),
                        c = a(c, r, f, h, n[o + 10], 9, 38016083),
                        h = a(h, c, r, f, n[o + 15], 14, -660478335),
                        f = a(f, h, c, r, n[o + 4], 20, -405537848),
                        r = a(r, f, h, c, n[o + 9], 5, 568446438),
                        c = a(c, r, f, h, n[o + 14], 9, -1019803690),
                        h = a(h, c, r, f, n[o + 3], 14, -187363961),
                        f = a(f, h, c, r, n[o + 8], 20, 1163531501),
                        r = a(r, f, h, c, n[o + 13], 5, -1444681467),
                        c = a(c, r, f, h, n[o + 2], 9, -51403784),
                        h = a(h, c, r, f, n[o + 7], 14, 1735328473),
                        r = s(r, f = a(f, h, c, r, n[o + 12], 20, -1926607734), h, c, n[o + 5], 4, -378558),
                        c = s(c, r, f, h, n[o + 8], 11, -2022574463),
                        h = s(h, c, r, f, n[o + 11], 16, 1839030562),
                        f = s(f, h, c, r, n[o + 14], 23, -35309556),
                        r = s(r, f, h, c, n[o + 1], 4, -1530992060),
                        c = s(c, r, f, h, n[o + 4], 11, 1272893353),
                        h = s(h, c, r, f, n[o + 7], 16, -155497632),
                        f = s(f, h, c, r, n[o + 10], 23, -1094730640),
                        r = s(r, f, h, c, n[o + 13], 4, 681279174),
                        c = s(c, r, f, h, n[o], 11, -358537222),
                        h = s(h, c, r, f, n[o + 3], 16, -722521979),
                        f = s(f, h, c, r, n[o + 6], 23, 76029189),
                        r = s(r, f, h, c, n[o + 9], 4, -640364487),
                        c = s(c, r, f, h, n[o + 12], 11, -421815835),
                        h = s(h, c, r, f, n[o + 15], 16, 530742520),
                        r = v(r, f = s(f, h, c, r, n[o + 2], 23, -995338651), h, c, n[o], 6, -198630844),
                        c = v(c, r, f, h, n[o + 7], 10, 1126891415),
                        h = v(h, c, r, f, n[o + 14], 15, -1416354905),
                        f = v(f, h, c, r, n[o + 5], 21, -57434055),
                        r = v(r, f, h, c, n[o + 12], 6, 1700485571),
                        c = v(c, r, f, h, n[o + 3], 10, -1894986606),
                        h = v(h, c, r, f, n[o + 10], 15, -1051523),
                        f = v(f, h, c, r, n[o + 1], 21, -2054922799),
                        r = v(r, f, h, c, n[o + 8], 6, 1873313359),
                        c = v(c, r, f, h, n[o + 15], 10, -30611744),
                        h = v(h, c, r, f, n[o + 6], 15, -1560198380),
                        f = v(f, h, c, r, n[o + 13], 21, 1309151649),
                        r = v(r, f, h, c, n[o + 4], 6, -145523070),
                        c = v(c, r, f, h, n[o + 11], 10, -1120210379),
                        h = v(h, c, r, f, n[o + 2], 15, 718787259),
                        f = v(f, h, c, r, n[o + 9], 21, -343485551),
                        r = l(r, e),
                        f = l(f, u),
                        h = l(h, p),
                        c = l(c, i);
                return [r, f, h, c]
            }(function(n) {
                var t, o = [];
                for (o[(n.length >> 2) - 1] = void 0,
                         t = 0; t < o.length; t += 1)
                    o[t] = 0;
                for (t = 0; t < 8 * n.length; t += 8)
                    o[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
                return o
            }(n), 8 * n.length))
        }
        function o(n) {
            return t(unescape(encodeURIComponent(n)))
        }
        return function(n) {
            var t, o, e = "0123456789abcdef", u = "";
            for (o = 0; o < n.length; o += 1)
                t = n.charCodeAt(o),
                    u += e.charAt(t >>> 4 & 15) + e.charAt(15 & t);
            return u
        }(o(n))
    }
        ,
        function r(f, h, c, l, g) {
            g = g || [[this], [{}]];
            for (var t = [], o = null, n = [function() {
                return !0
            }
                , function() {}
                , function() {
                    g.length = c[h++]
                }
                , function() {
                    g.push(c[h++])
                }
                , function() {
                    g.pop()
                }
                , function() {
                    var n = c[h++]
                        , t = g[g.length - 2 - n];
                    g[g.length - 2 - n] = g.pop(),
                        g.push(t)
                }
                , function() {
                    g.push(g[g.length - 1])
                }
                , function() {
                    g.push([g.pop(), g.pop()].reverse())
                }
                , function() {
                    g.push([l, g.pop()])
                }
                , function() {
                    g.push([g.pop()])
                }
                , function() {
                    var n = g.pop();
                    g.push(n[0][n[1]])
                }
                , function() {
                    g.push(g[g.pop()[0]][0])
                }
                , function() {
                    var n = g[g.length - 2];
                    n[0][n[1]] = g[g.length - 1]
                }
                , function() {
                    g[g[g.length - 2][0]][0] = g[g.length - 1]
                }
                , function() {
                    var n = g.pop()
                        , t = g.pop();
                    g.push([t[0][t[1]], n])
                }
                , function() {
                    var n = g.pop();
                    g.push([g[g.pop()][0], n])
                }
                , function() {
                    var n = g.pop();
                    g.push(delete n[0][n[1]])
                }
                , function() {
                    var n = [];
                    for (var t in g.pop())
                        n.push(t);
                    g.push(n)
                }
                , function() {
                    g[g.length - 1].length ? g.push(g[g.length - 1].shift(), !0) : g.push(void 0, !1)
                }
                , function() {
                    var n = g[g.length - 2]
                        , t = Object.getOwnPropertyDescriptor(n[0], n[1]) || {
                        configurable: !0,
                        enumerable: !0
                    };
                    t.get = g[g.length - 1],
                        Object.defineProperty(n[0], n[1], t)
                }
                , function() {
                    var n = g[g.length - 2]
                        , t = Object.getOwnPropertyDescriptor(n[0], n[1]) || {
                        configurable: !0,
                        enumerable: !0
                    };
                    t.set = g[g.length - 1],
                        Object.defineProperty(n[0], n[1], t)
                }
                , function() {
                    h = c[h++]
                }
                , function() {
                    var n = c[h++];
                    g[g.length - 1] && (h = n)
                }
                , function() {
                    throw g[g.length - 1]
                }
                , function() {
                    var n = c[h++]
                        , t = n ? g.slice(-n) : [];
                    g.length -= n,
                        g.push(g.pop().apply(l, t))
                }
                , function() {
                    var n = c[h++]
                        , t = n ? g.slice(-n) : [];
                    g.length -= n;
                    var o = g.pop();
                    g.push(o[0][o[1]].apply(o[0], t))
                }
                , function() {
                    var n = c[h++]
                        , t = n ? g.slice(-n) : [];
                    g.length -= n,
                        t.unshift(null),
                        g.push(new (Function.prototype.bind.apply(g.pop(), t)))
                }
                , function() {
                    var n = c[h++]
                        , t = n ? g.slice(-n) : [];
                    g.length -= n,
                        t.unshift(null);
                    var o = g.pop();
                    g.push(new (Function.prototype.bind.apply(o[0][o[1]], t)))
                }
                , function() {
                    g.push(!g.pop())
                }
                , function() {
                    g.push(~g.pop())
                }
                , function() {
                    g.push(typeof g.pop())
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] == g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] === g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] > g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] >= g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] << g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] >> g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] >>> g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] + g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] - g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] * g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] / g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] % g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] | g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] & g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] ^ g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2]in g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2]instanceof g.pop()
                }
                , function() {
                    g[g[g.length - 1][0]] = void 0 === g[g[g.length - 1][0]] ? [] : g[g[g.length - 1][0]]
                }
                , function() {
                    for (var e = c[h++], u = [], n = c[h++], t = c[h++], p = [], o = 0; o < n; o++)
                        u[c[h++]] = g[c[h++]];
                    for (var i = 0; i < t; i++)
                        p[i] = c[h++];
                    g.push(function n() {
                        var t = u.slice(0);
                        t[0] = [this],
                            t[1] = [arguments],
                            t[2] = [n];
                        for (var o = 0; o < p.length && o < arguments.length; o++)
                            0 < p[o] && (t[p[o]] = [arguments[o]]);
                        return r(f, e, c, l, t)
                    })
                }
                , function() {
                    t.push([c[h++], g.length, c[h++]])
                }
                , function() {
                    t.pop()
                }
                , function() {
                    return !!o
                }
                , function() {
                    o = null
                }
                , function() {
                    g[g.length - 1] += String.fromCharCode(c[h++])
                }
                , function() {
                    g.push("")
                }
                , function() {
                    g.push(void 0)
                }
                , function() {
                    g.push(null)
                }
                , function() {
                    g.push(!0)
                }
                , function() {
                    g.push(!1)
                }
                , function() {
                    g.length -= c[h++]
                }
                , function() {
                    g[g.length - 1] = c[h++]
                }
                , function() {
                    var n = g.pop()
                        , t = g[g.length - 1];
                    t[0][t[1]] = g[n[0]][0]
                }
                , function() {
                    var n = g.pop()
                        , t = g[g.length - 1];
                    t[0][t[1]] = n[0][n[1]]
                }
                , function() {
                    var n = g.pop()
                        , t = g[g.length - 1];
                    g[t[0]][0] = g[n[0]][0]
                }
                , function() {
                    var n = g.pop()
                        , t = g[g.length - 1];
                    g[t[0]][0] = n[0][n[1]]
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] < g.pop()
                }
                , function() {
                    g[g.length - 2] = g[g.length - 2] <= g.pop()
                }
            ]; ; )
                try {
                    for (; !n[c[h++]](); )
                        ;
                    if (o)
                        throw o;
                    return g.pop()
                } catch (n) {
                    var e = t.pop();
                    if (void 0 === e)
                        throw n;
                    o = n,
                        h = e[0],
                        g.length = e[1],
                    e[2] && (g[e[2]][0] = o)
                }
        }(120731, 0, [21, 34, 50, 100, 57, 50, 102, 50, 98, 99, 101, 52, 54, 97, 52, 99, 55, 56, 52, 49, 57, 54, 57, 49, 56, 98, 102, 100, 100, 48, 48, 55, 55, 102, 2, 10, 3, 2, 9, 48, 61, 3, 9, 48, 61, 4, 9, 48, 61, 5, 9, 48, 61, 6, 9, 48, 61, 7, 9, 48, 61, 8, 9, 48, 61, 9, 9, 48, 4, 21, 427, 54, 2, 15, 3, 2, 9, 48, 61, 3, 9, 48, 61, 4, 9, 48, 61, 5, 9, 48, 61, 6, 9, 48, 61, 7, 9, 48, 61, 8, 9, 48, 61, 9, 9, 48, 61, 10, 9, 48, 61, 11, 9, 48, 61, 12, 9, 48, 61, 13, 9, 48, 61, 14, 9, 48, 61, 10, 9, 55, 54, 97, 54, 98, 54, 99, 54, 100, 54, 101, 54, 102, 54, 103, 54, 104, 54, 105, 54, 106, 54, 107, 54, 108, 54, 109, 54, 110, 54, 111, 54, 112, 54, 113, 54, 114, 54, 115, 54, 116, 54, 117, 54, 118, 54, 119, 54, 120, 54, 121, 54, 122, 54, 48, 54, 49, 54, 50, 54, 51, 54, 52, 54, 53, 54, 54, 54, 55, 54, 56, 54, 57, 13, 4, 61, 11, 9, 55, 54, 77, 54, 97, 54, 116, 54, 104, 8, 55, 54, 102, 54, 108, 54, 111, 54, 111, 54, 114, 14, 55, 54, 77, 54, 97, 54, 116, 54, 104, 8, 55, 54, 114, 54, 97, 54, 110, 54, 100, 54, 111, 54, 109, 14, 25, 0, 3, 4, 9, 11, 3, 3, 9, 11, 39, 3, 1, 38, 40, 3, 3, 9, 11, 38, 25, 1, 13, 4, 61, 12, 9, 55, 13, 4, 61, 13, 9, 3, 0, 13, 4, 4, 3, 13, 9, 11, 3, 11, 9, 11, 66, 22, 306, 4, 21, 422, 24, 4, 3, 14, 9, 55, 54, 77, 54, 97, 54, 116, 54, 104, 8, 55, 54, 102, 54, 108, 54, 111, 54, 111, 54, 114, 14, 55, 54, 77, 54, 97, 54, 116, 54, 104, 8, 55, 54, 114, 54, 97, 54, 110, 54, 100, 54, 111, 54, 109, 14, 25, 0, 3, 10, 9, 55, 54, 108, 54, 101, 54, 110, 54, 103, 54, 116, 54, 104, 15, 10, 40, 25, 1, 13, 4, 61, 12, 9, 6, 11, 3, 10, 9, 3, 14, 9, 11, 15, 10, 38, 13, 4, 61, 13, 9, 6, 11, 6, 5, 1, 5, 0, 3, 1, 38, 13, 4, 61, 0, 5, 0, 43, 4, 21, 291, 61, 3, 12, 9, 11, 0, 3, 9, 9, 49, 72, 0, 2, 3, 4, 13, 4, 61, 8, 9, 21, 721, 3, 2, 8, 3, 2, 9, 48, 61, 3, 9, 48, 61, 4, 9, 48, 61, 5, 9, 48, 61, 6, 9, 48, 61, 7, 9, 48, 4, 55, 54, 115, 54, 101, 54, 108, 54, 102, 8, 10, 30, 55, 54, 117, 54, 110, 54, 100, 54, 101, 54, 102, 54, 105, 54, 110, 54, 101, 54, 100, 32, 28, 22, 510, 4, 21, 523, 22, 4, 55, 54, 115, 54, 101, 54, 108, 54, 102, 8, 10, 0, 55, 54, 119, 54, 105, 54, 110, 54, 100, 54, 111, 54, 119, 8, 10, 30, 55, 54, 117, 54, 110, 54, 100, 54, 101, 54, 102, 54, 105, 54, 110, 54, 101, 54, 100, 32, 28, 22, 566, 4, 21, 583, 3, 4, 55, 54, 119, 54, 105, 54, 110, 54, 100, 54, 111, 54, 119, 8, 10, 0, 55, 54, 103, 54, 108, 54, 111, 54, 98, 54, 97, 54, 108, 8, 10, 30, 55, 54, 117, 54, 110, 54, 100, 54, 101, 54, 102, 54, 105, 54, 110, 54, 101, 54, 100, 32, 28, 22, 626, 4, 21, 643, 25, 4, 55, 54, 103, 54, 108, 54, 111, 54, 98, 54, 97, 54, 108, 8, 10, 0, 55, 54, 69, 54, 114, 54, 114, 54, 111, 54, 114, 8, 55, 54, 117, 54, 110, 54, 97, 54, 98, 54, 108, 54, 101, 54, 32, 54, 116, 54, 111, 54, 32, 54, 108, 54, 111, 54, 99, 54, 97, 54, 116, 54, 101, 54, 32, 54, 103, 54, 108, 54, 111, 54, 98, 54, 97, 54, 108, 54, 32, 54, 111, 54, 98, 54, 106, 54, 101, 54, 99, 54, 116, 27, 1, 23, 56, 0, 49, 444, 0, 0, 24, 0, 13, 4, 61, 8, 9, 55, 54, 95, 54, 95, 54, 103, 54, 101, 54, 116, 54, 83, 54, 101, 54, 99, 54, 117, 54, 114, 54, 105, 54, 116, 54, 121, 54, 83, 54, 105, 54, 103, 54, 110, 15, 21, 1126, 49, 2, 14, 3, 2, 9, 48, 61, 3, 9, 48, 61, 4, 9, 48, 61, 5, 9, 48, 61, 6, 9, 48, 61, 7, 9, 48, 61, 8, 9, 48, 61, 9, 9, 48, 61, 10, 9, 48, 61, 11, 9, 48, 61, 9, 9, 55, 54, 108, 54, 111, 54, 99, 54, 97, 54, 116, 54, 105, 54, 111, 54, 110, 8, 10, 30, 55, 54, 117, 54, 110, 54, 100, 54, 101, 54, 102, 54, 105, 54, 110, 54, 101, 54, 100, 32, 28, 22, 862, 21, 932, 21, 4, 55, 54, 108, 54, 111, 54, 99, 54, 97, 54, 116, 54, 105, 54, 111, 54, 110, 8, 55, 54, 104, 54, 111, 54, 115, 54, 116, 14, 55, 54, 105, 54, 110, 54, 100, 54, 101, 54, 120, 54, 79, 54, 102, 14, 55, 54, 121, 54, 46, 54, 113, 54, 113, 54, 46, 54, 99, 54, 111, 54, 109, 25, 1, 3, 0, 3, 1, 39, 32, 22, 963, 4, 55, 54, 67, 54, 74, 54, 66, 54, 80, 54, 65, 54, 67, 54, 114, 54, 82, 54, 117, 54, 78, 54, 121, 54, 55, 21, 974, 50, 4, 3, 12, 9, 11, 3, 8, 3, 10, 24, 2, 13, 4, 61, 10, 9, 3, 13, 9, 55, 54, 95, 54, 95, 54, 115, 54, 105, 54, 103, 54, 110, 54, 95, 54, 104, 54, 97, 54, 115, 54, 104, 54, 95, 54, 50, 54, 48, 54, 50, 54, 48, 54, 48, 54, 51, 54, 48, 54, 53, 15, 10, 22, 1030, 21, 1087, 22, 4, 3, 13, 9, 55, 54, 95, 54, 95, 54, 115, 54, 105, 54, 103, 54, 110, 54, 95, 54, 104, 54, 97, 54, 115, 54, 104, 54, 95, 54, 50, 54, 48, 54, 50, 54, 48, 54, 48, 54, 51, 54, 48, 54, 53, 15, 3, 9, 9, 11, 3, 3, 9, 11, 38, 25, 1, 13, 4, 61, 11, 9, 3, 12, 9, 11, 3, 10, 3, 53, 3, 37, 39, 24, 2, 13, 4, 4, 55, 54, 122, 54, 122, 54, 97, 3, 11, 9, 11, 38, 3, 10, 9, 11, 38, 0, 49, 771, 2, 1, 12, 9, 13, 8, 3, 12, 4, 4, 56, 0], n);
    var t = n.__getSecuritySign;
    return t;
});

function getSign(data){
    return this.__getSecuritySign(data);
}

 

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
当使用QQ扫码登录时,通常需要使用QQ提供的开放平台API来实现。以下是一个使用Python编写的示例代码,用于实现QQ扫码登录功能: ```python import requests # 获取授权码 def get_auth_code(): # 替换为你的AppID和回调地址 app_id = 'your_app_id' redirect_uri = 'your_redirect_uri' # 构造请求URL url = f'https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id={app_id}&redirect_uri={redirect_uri}' # 发送GET请求获取授权码 response = requests.get(url) # 解析返回的URL,提取授权码 auth_code = response.url.split('=')[1] return auth_code # 获取访问令牌 def get_access_token(auth_code): # 替换为你的AppID、AppKey和回调地址 app_id = 'your_app_id' app_key = 'your_app_key' redirect_uri = 'your_redirect_uri' # 构造请求URL url = f'https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id={app_id}&client_secret={app_key}&code={auth_code}&redirect_uri={redirect_uri}' # 发送GET请求获取访问令牌 response = requests.get(url) # 解析返回的URL,提取访问令牌 access_token = response.text.split('&')[0].split('=')[1] return access_token # 获取用户信息 def get_user_info(access_token): # 构造请求URL url = f'https://graph.qq.com/oauth2.0/me?access_token={access_token}' # 发送GET请求获取用户OpenID response = requests.get(url) # 解析返回的JSON数据,提取OpenID openid = response.text.split('"')[3] # 构造请求URL url = f'https://graph.qq.com/user/get_user_info?access_token={access_token}&oauth_consumer_key={app_id}&openid={openid}' # 发送GET请求获取用户信息 response = requests.get(url) # 解析返回的JSON数据,提取用户信息 user_info = response.json() return user_info # 示例代码的使用 auth_code = get_auth_code() access_token = get_access_token(auth_code) user_info = get_user_info(access_token) print(user_info) ``` 请注意,上述代码中的`your_app_id`、`your_app_key`和`your_redirect_uri`需要替换为你在QQ开放平台申请的实际值。此外,你还需要安装`requests`库来发送HTTP请求。 希望以上代码能够帮助到你!如果你有任何其他问题,请随时提问。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值