手机号性别检测

手机号性别检测 手机号实名检测

我们通过程序进行

比如 appium自动化测试工具,adb命令,android自动化测试Uiautomator框架 等。。

adb命令通用,python调用adb很方便,所以那我们就用adb写自动获取代码。

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<hierarchy rotation="0">
    <node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.tencent.mm" content-desc="当前所在页面,详细资料" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,1920]">
        <node index="0" text="" resource-id="com.tencent.mm:id/dgn" class="android.widget.FrameLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,1920]">
            <node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,1920]">
                <node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,1920]">
                    <node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,60][1080,1920]">
                        <node index="0" text="" resource-id="com.tencent.mm:id/gz" class="android.view.ViewGroup" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,60][1080,1920]">
                            <node index="0" text="" resource-id="com.tencent.mm:id/h0" class="android.widget.FrameLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,60][1080,204]">
                                <node index="0" text="" resource-id="com.tencent.mm:id/h1" class="android.view.ViewGroup" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,60][1080,204]">
                                    <node index="0" text="" resource-id="com.tencent.mm:id/gw" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,60][912,204]">
                                        <node index="0" text="" resource-id="com.tencent.mm:id/i1" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,60][146,204]">
                                            <node index="0" text="" resource-id="com.tencent.mm:id/i2" class="android.widget.ImageView" package="com.tencent.mm" content-desc="返回" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,60][144,204]" />
                                            <node index="1" text="" resource-id="com.tencent.mm:id/hf" class="android.widget.ImageView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[144,96][146,168]" /></node>
                                        <node index="1" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[182,60][398,204]">
                                            <node index="0" text="详细资料" resource-id="android:id/text1" class="android.widget.TextView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[182,95][398,168]" /></node>
                                    </node>
                                    <node index="1" text="" resource-id="" class="android.support.v7.widget.LinearLayoutCompat" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[912,60][1080,204]">
                                        <node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[912,60][1080,204]">
                                            <node index="0" text="" resource-id="" class="android.widget.RelativeLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[912,60][1080,204]">
                                                <node index="0" text="" resource-id="com.tencent.mm:id/hi" class="android.widget.ImageButton" package="com.tencent.mm" content-desc="更多" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[912,60][1080,204]" /></node>
                                        </node>
                                    </node>
                                </node>
                            </node>
                            <node index="1" text="" resource-id="android:id/content" class="android.widget.FrameLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,204][1080,1920]">
                                <node index="0" text="" resource-id="com.tencent.mm:id/c8f" class="android.widget.FrameLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,204][1080,1920]">
                                    <node index="0" text="" resource-id="com.tencent.mm:id/c_z" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,204][1080,1920]">
                                        <node index="0" text="" resource-id="android:id/list" class="android.widget.ListView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="true" scrollable="false" long-clickable="true" password="false" selected="false" bounds="[0,204][1080,1920]">
                                            <node index="0" text="" resource-id="android:id/title" class="android.widget.TextView" package="com.tencent.mm" content-desc="分隔栏" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,204][1080,264]" />
                                            <node index="1" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,264][1080,726]">
                                                <node index="0" text="" resource-id="com.tencent.mm:id/anj" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,264][1080,528]">
                                                    <node index="0" text="" resource-id="com.tencent.mm:id/pz" class="android.widget.ImageView" package="com.tencent.mm" content-desc="头像" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[42,300][234,492]" />
                                                    <node index="1" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[306,300][1044,383]">
                                                        <node index="0" text="" resource-id="com.tencent.mm:id/ank" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[306,306][1044,371]">
                                                            <node index="0" text="李鹏 " resource-id="com.tencent.mm:id/q0" class="android.widget.TextView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[306,306][414,371]" />
                                                            <node index="1" text="" resource-id="com.tencent.mm:id/anl" class="android.widget.ImageView" package="com.tencent.mm" content-desc="男" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[423,308][484,369]" /></node>
                                                    </node>
                                                </node>
                                                <node index="1" text="" resource-id="" class="android.widget.TextView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,528][1080,529]" />
                                                <node index="2" text="" resource-id="com.tencent.mm:id/anz" class="android.view.View" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,529][1080,589]" />
                                                <node index="3" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,589][1080,726]">
                                                    <node index="0" text="设置备注和标签" resource-id="com.tencent.mm:id/ao0" class="android.widget.TextView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,589][1080,726]" /></node>
                                            </node>
                                            <node index="2" text="" resource-id="android:id/title" class="android.widget.TextView" package="com.tencent.mm" content-desc="分隔栏" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,726][1080,786]" />
                                            <node index="3" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="false" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,786][1080,930]">
                                                <node index="0" text="" resource-id="com.tencent.mm:id/ij" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="false" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[42,786][1038,930]">
                                                    <node index="0" text="" resource-id="com.tencent.mm:id/jg" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="false" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[42,801][496,914]">
                                                        <node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="false" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[42,825][288,890]">
                                                            <node index="0" text="地区" resource-id="android:id/title" class="android.widget.TextView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="false" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[42,825][288,890]" /></node>
                                                        <node index="1" text="" resource-id="com.tencent.mm:id/c_d" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="false" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[306,829][496,885]">
                                                            <node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="false" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[306,829][496,885]">
                                                                <node index="0" text="河南  信阳" resource-id="android:id/summary" class="android.widget.TextView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="false" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[306,829][496,885]" /></node>
                                                        </node>
                                                    </node>
                                                </node>
                                            </node>
                                            <node index="4" text="" resource-id="android:id/title" class="android.widget.TextView" package="com.tencent.mm" content-desc="分隔栏" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,930][1080,990]" />
                                            <node index="5" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,990][1080,1170]">
                                                <node index="0" text="添加到通讯录" resource-id="com.tencent.mm:id/an_" class="android.widget.Button" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[42,990][1038,1134]" /></node>
                                            <node index="6" text="" resource-id="android:id/title" class="android.widget.TextView" package="com.tencent.mm" content-desc="分隔栏" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,1170][1080,1230]" />
                                            <node index="7" text="" resource-id="" class="android.widget.LinearLayout" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,1230][1080,1310]">
                                                <node index="0" text="" resource-id="android:id/title" class="android.widget.TextView" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,1230][1080,1310]" /></node>
                                        </node>
                                    </node>
                                </node>
                            </node>
                        </node>
                    </node>
                </node>
            </node>
        </node>
        <node index="1" text="" resource-id="android:id/statusBarBackground" class="android.view.View" package="com.tencent.mm" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,60]" /></node>
</hierarchy>

发现 性别在 content-desc=”男” 这个地方 ,

一共有三种状态

content-desc=”男”
content-desc=”女”
xml源码没有就是对方性别未知
找到包含 resource-id=”com.tencent.mm:id/anl” 为基准的节点,包含在
我们先找到包含resource-id=”com.tencent.mm:id/anl”的这一行,

1 首先获取手机设备
2 电脑端使用python程序通过adb命令控制手机
3 拿出手机端的页面
4 进行匹配并打印
开始我们的编写代码:

import os,re
# 获取所有的手机设备
def getDevicesAll():
    devices = []
    try:
        for dName_ in os.popen("adb devices"):
            if "\t" in dName_:
                if dName_.find("emulator") < 0:
                    devices.append(dName_.split("\t")[0])
        devices.sort(cmp=None, key=None, reverse=False)
    except:
        pass
    print(u"\n设备名称: %s \n总数量:%s台" % (devices, len(devices)))
    return devices
# 导出手机端当前页面元素
def export(devices_name):
    # 页面xml保存到手机存储
    step1 = os.popen('adb -s {0} shell uiautomator dump /sdcard/{1}.xml'.format(devices_name,devices_name)).read()
    if step1.find('UI') != -1:
        print(devices_name+'\txml写进手机存储成功')
        # 页面xml从手机存储推送到电脑,和当前运行程序同级
        os.popen('adb -s {0} pull /sdcard/{1}.xml '.format(devices_name,devices_name))
        print(devices_name+"\txml推送到电脑成功")
        with open(devices_name + ".xml",encoding="utf-8") as f:
            res = f.read()
        return res
    else:
        print(devices_name+"\txml写进手机存储失败")
    return "null"
# 匹配函数
def check_line(res,find_str):
    list1 = re.findall( '<[^<]*?' + find_str + '[^>]*?>', res)
    if list1:
        return list1[0]
    return "null"

def main():
    # 以resource-id为基准进行匹配
    findstr = 'resource-id="com.tencent.mm:id/anl"'
    devices = getDevicesAll()
    for d_name in devices:
        res = export(d_name)
        if res!="null":
            result = check_line(res,findstr)
            if result=="null":
                print("此手机号性别未知")
            elif result.find("男") != -1:
                print("此手机号性别男")
            elif result.find("女") != -1:
                print("此手机号性别女")
if __name__=="__main__":
    main()
————————————————

getDevicesAll函数获取所有连接电脑的USB手机设备,获取设备名称
export函数获取当前连接的手机的页面
check_line函数拿到准确的一行,拿不到说明是未知性别
main函数进行逻辑判断等。

有需求的可以联系我!

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 5

Q 1315619

2个月前 评论
自由与温暖是遥不可及的梦想

是否需要 手机设备 还是只是需要一个手机号即可

2个月前 评论
october

有点虎头蛇尾的。

2个月前 评论

手机号怎么知道性别的?难道你有实名制资料

2个月前 评论

和这篇文章比,少了很多哎,差点没看明白
Python 通过手机号获取微信男女性别-作者:我不喜欢这个世界
我还以为是能用接口形式直接获取到,,
手机号是可以直接转户的,带上双方身份证就行,应该不存在区分男女的算法

2个月前 评论

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
未填写
文章
1
粉丝
0
喜欢
0
收藏
0
排名:1561
访问:460
私信
所有博文