吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5477|回复: 14
收起左侧

[其他转载] auto.js分析微信VX界面,得到发言人、发言内容,输出json

[复制链接]
52Douyin 发表于 2020-7-17 21:11
相信很多人都写过vx机器人,有基于ui界面进行操作的,还有基于协议。今天为大家分享的是我以前写的可以从v微信x界面
分析某人分享的链接或者发布的文字内容。
开发工具auto.js4.x;
下面先为大家介绍一下实现思路,上图
001.jpg

看红框处,分析可以看出来,AA发布的内容,是在UIobject里面(android.widget.LinearLayout);
理论上,我只要遍历(android.widget.LinearLayout)的子集就可以找到文本内容,进行分析了
——————下面给大家上代码,代码写的时间比较久了,大家可以做优化,此处只是实现功能
[Java] 纯文本查看 复制代码
let _index = 0;//当前索引
/**所有人员姓名 */
let allBodyName = new Array();
//发言人:内容模块:包含发言人姓名,发言内容;
let OneYuan = className("android.widget.LinearLayout").depth(12).find();
if (!OneYuan.empty()) {
    for (let obj of OneYuan) {

        //id序号,TalkName发言人,TalkContent发言内容,LinkTitle发布的标题,LinkDesc简介,
        var str = { "id": "", "TalkName": "", "TalkContent": "", "LinkTitle": "", "LinkDesc": "", "LinkSource": "" };

        //log("[obj]=>" + obj.className() );
        obj.children().forEach(function (child) {
            

            log("【01.child】" + child.className()+"  text? "+child.text());//+" = "+ child.id()
            if ("android.widget.TextView" == child.className()) {
                log(" <发言人>" + child.text() );//+ " id " + child.id()
                str.TalkName = child.text();
                str.id = _index++;
            }

            if ("android.view.View" == child.className() && "com.tencent.mm:id/ala" == child.id()) {

                log("View.id>>【双击打开】:" + child.id());
                click(child.bounds().centerX(), child.bounds().centerY());
                sleep(50);
                click(child.bounds().centerX(), child.bounds().centerY());
                sleep(3000);
                let getText = className("android.widget.TextView").depth(9).findOne(500);
                if (getText) {
                    log("《发言》" + getText.text());
                    str.TalkContent = getText.text();
                    // //存储
                    // allBodyName.push(str);
                }
                sleep(2000);
                back();
                sleep(2000);
            }

            if ("android.widget.LinearLayout" == child.className()) {
                log("LinearLayout>>find超链接集合,简介+来源 = [text] " + child.text());
                child.children().forEach(function (item) {

                    if ("android.widget.LinearLayout" == item.className()) {
                        log("[item text] " + item.text());
                        item.children().forEach(function (next0) {
                            log("[next0 text] " + next0.text());
                            next0.children().forEach(function (next1) {
                                log("[next1 text] " + next1.text());
                                next1.children().forEach(function (next2) {
                                    log("[next2 text] " + next2.text());
                                    next2.children().forEach(function (next3) {
                                        log("[next3 text] " + next3.text());
                                        
                                        if ("android.widget.TextView" == next3.className()) {
                                            log("next3【链接标题】:" + next3.text());
                                            str.LinkTitle = next3.text();
                                        }
                                        if ("android.widget.LinearLayout" == next3.className()) {
                                            next3.children().forEach(function (next4) {

                                                if ("android.widget.LinearLayout" == next4.className()) {
                                                    next4.children().forEach(function (next5) {

                                                        if ("android.widget.LinearLayout" == next5.className()) {
                                                            next5.children().forEach(function (next50) {
                                                                log("next50《简介》:" + next50.className() + " = " + next50.text());
                                                                str.LinkDesc = next50.text();
                                                            });
                                                        }
                                                        if ("android.widget.RelativeLayout" == next5.className()) {
                                                            next5.children().forEach(function (next51) {
                                                                if ("android.widget.TextView" == next51.className()) {
                                                                    log("next51《来源》: = " + next51.text() + "--" + next51.className());
                                                                    //有的没有来源
                                                                    str.LinkSource = next51.text();
                                                                }
                                                            });
                                                        }
                                                        //找到'小程序'标签
                                                        if("android.widget.TextView" == next5.className()){
                                                            //log("小程序>>"+next5.text());
                                                            str.LinkSource = next5.text()
                                                        }

                                                    })
                                                }//next4
                                            });
                                        }
                                    });//next2
                                });//next1
                            });
                        });
                    }

                });
            }

        });

        ///log("==="+ str.TalkName);
        // //有的没有【来源】
        // //存储
        if(str.TalkName!=null && str.TalkName!=""){
            allBodyName.push(str);
        }
        
        // if (str && str.TalkName != "") {
        //     log("保存完成,一次循环,记录提取的数据!!>>记得查看数据>>>");
        // }

        sleep(2000);

    }
}
else {
    log("没找到'发言元素'");
}

log("lens->" + allBodyName.length);
for (let k = 0; k < allBodyName.length; k++) {
    log("PPPPP "+JSON.stringify(allBodyName[k]));
}


提示:如果是用户发送的文本内容, 需要双击之后,才能提取到,上面也已经实现了。大家可以看代码测试。

微信截图_20200717210813.png

可以把对话保存成json格式,输出或者保存。

————代码是以前写的,运行没问题。大家自行调试。比起调用协议,这种实现方式有些复杂,好处是兼容性好,不会因为官方更新接口导致失效。
  我现在写的vx机器人是调用协议,思路都差不多,供大家参考

觉得好的,给个好评啊!!!

免费评分

参与人数 4吾爱币 +8 热心值 +4 收起 理由
Joniak + 1 + 1 我很赞同!
苏紫方璇 + 5 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
crb8331 + 1 + 1 热心回复!
1358582642 + 1 + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 52Douyin 发表于 2020-7-19 11:02
当时实现了功能,没有做优化;
用户的发言都是嵌套在"android.widget.LinearLayout"里面的。
所以在遍历子集的时候,做了判断。
takpap 发表于 2020-7-17 21:27
sitiger 发表于 2020-7-17 21:36
Xiao伟 发表于 2020-7-17 21:42
AUTO.JS 能实现自动回复功能吗? 就跟智能机器人那样
nulla2011 发表于 2020-7-17 22:32
这个看上去不错啊
头像被屏蔽
whatskey 发表于 2020-7-17 22:48
提示: 作者被禁止或删除 内容自动屏蔽
Clearloveu 发表于 2020-7-18 00:11
收藏再说,感谢分享
 楼主| 52Douyin 发表于 2020-7-18 20:56
感谢各位同学的鼓励!!!!!!!!!!!!!!!!!
大侠在路上 发表于 2020-7-18 22:32
感谢楼主分享,帖子写得很棒,唯独的缺点就是if一套一套的,我看得头有点大了。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-9 23:21

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表