目 录CONTENT

文章目录

导出Postwoman谷歌插件的接口数据

Stars-one
2026-01-31 / 0 评论 / 0 点赞 / 2 阅读 / 0 字

记录下导出postwoman的插件里保存的接口数据

在postwoman页面打开console输入执行即可输出一个个json文本(会自动复制)

背景是我想转为Bruno这款开源api接口调试工具,发现postwoman插件里没有导出的功能

var result = [];
    
    $('#modules .panel').each(function() {
        var module = {};
        
        // 获取模块名称
        var moduleName = $(this).find('.cursor').text().trim();
        module.name = moduleName;
        module.interfaces = [];
        
        // 获取该模块下的所有接口
        $(this).find('.panel-body .interface').each(function() {
            var interface = {};
            var dataAttr = $(this).attr('crap-data');
            
            if (dataAttr) {
                // 解码URL编码的JSON数据
                var decodedData = decodeURIComponent(dataAttr);
                var dataObj = JSON.parse(decodedData);
                
                interface.id = dataObj.id;
                interface.name = dataObj.name;
                interface.method = dataObj.method;
                interface.url = dataObj.url;
                interface.moduleId = dataObj.moduleId;
                interface.paramType = dataObj.paramType;
            }
            
            module.interfaces.push(interface);
        });
        
        result.push(module);
    });
    
    console.log(JSON.stringify(result, null, 2));
    var resultStr = JSON.stringify(result, null, 2);
    copy(resultStr)
0

评论区