视频教程

https://www.bilibili.com/video/BV1aN4y1V7cb/

传统RPC

插入websocket相关代码

!function () {
    if (!window._makeRequest){
        window._makeRequest = makeRequest;
        var ws = new WebSocket("ws://127.0.0.1:16666");
        ws.open = function (param){};
        ws.onmessage=function(param){
            var mdata=param.data;
            var u=mdata.split('|')[0]
            var p=mdata.split('|')[1]
            var result = window._makeRequest(u,p, 7, false);
            ws.send(JSON.stringify(result))
        }
    }
}();

Python websocket Server

# -*- coding: utf-8 -*-
# @Author: Null119 微信公众号/网站:治廷君
# @Desc: { js RPC示例 }
# @Date: { 2022/8/18 }
import asyncio,websockets

async def recv_msg(websocket):
    while True:
        print(await websocket.recv())

async def main(websocket,path):
    await websocket.send('13388888888|testtest22222')
    await recv_msg(websocket)

server=websockets.serve(main,'127.0.0.1',16666)
asyncio.get_event_loop().run_until_complete(server)
asyncio.get_event_loop().run_forever()

Sekiro框架

官方文档地址

https://sekiro.virjar.com/sekiro-doc/

demoServer下载地址

https://null119.lanzoul.com/iHdw709rydba

插入JS代码

if(!window._makeRequest){window._makeRequest = makeRequest}

通过油猴加载sekiro_web_client及SekiroClient相关代码

// ==UserScript==
// @name         sekrio
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://weibo.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=jianshu.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    var _mscript=document.createElement("script")
    _mscript.src="https://sekiro.virjar.com/sekiro-doc/assets/sekiro_web_client.js"
    document.body.appendChild(_mscript);
    function sek_start(){
        function guid() {
            function S4() {
                return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
            }
            return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
        }
        var client = new SekiroClient("ws://127.0.0.1:5620/business-demo/register?group=test&clientId=" + guid());
        client.registerAction("makeRequest", function (request, resolve, reject) {
            try {
                var _user=request['user']
                var _psw=request['psw']
                var result=JSON.stringify(window._makeRequest(_user,_psw,7,false))
                resolve(result);
            } catch (e) {
                reject("error: " + e);
            }
        });
    }
    setTimeout(sek_start,2000)
})();

RPC调用(python示例)

# -*- coding: utf-8 -*-
# @Author: Null119 微信公众号/网站:治廷君
# @Desc: { 微博登录Sekiro_RPC示例 }
# @Date: { 2022/8/18 }

import requests

r=requests.Session()
pdata={
    'group':'test',
    'action':'makeRequest',
    'user':'13255557777',
    'psw':'8888888567'
}

response=requests.get("http://127.0.0.1:5620/business-demo/invoke",params=pdata)
print(response.text)

本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习使用,请在下载后24小时内删除,严禁商用。若由于商用引起版权纠纷,一切责任均由使用者承担。 【注意:本站发布资源来源于网络搜集,均有较强时效性,请在下载前注意查看文章资源发布或更新时间,距离当前时间太久的资源不建议下载,特别是安卓专区相关资源,会有大概率失效无法使用】