Python实现手机号自动判断男女性别(实例解析)

作者:西西里传说 时间:2021-06-24 21:47:28 

本文性别判断主要依靠airtest中的自动化测试实现

通过自动对比支付宝页面男女图像,从而实现男女判断

Python实现手机号自动判断男女性别(实例解析)Python实现手机号自动判断男女性别(实例解析)

代码如下:

男女判断函数:


// An highlighted block
def numbe():
 if exists(Template(r"tpl1574867500094.png", threshold=0.85, rgb=True, target_pos=0, record_pos=(0.779, 0.382), resolution=(960, 540))):
   sex = "女"  
 if exists(Template(r"tpl1574924960910.png", threshold=0.89, rgb=True, target_pos=5, record_pos=(0.779, 0.382), resolution=(960, 540))):
   sex = "男"
 else:
   sex = "不存在"
 namesex = sex
 keyevent("4")
 return namesex

手机滑动(根据手机分辨率自行调整):

// An highlighted block
def scoll():
 try:
   swipe(v1=(629, 1750),v2=(629, 310)) # 滑动距离需要根据手机分辨率自行调整        
 except:
   print("can't go back to the main page")

刷选函数:


// An highlighted block
def number():  
 data_list =[]
 for i in range(9): # 根据手机分辨率自行调整
   try:
     title =poco(name="com.alipay.mobile.contactsapp:id/contact_item_name")[i].get_text()
     name = poco(name="com.alipay.mobile.contactsapp:id/concast_from")[i].get_text()
     print(title)
     name_a =name[5:6]
     if title not in data_list and name_a is not "1":
       poco("com.alipay.mobile.contactsapp:id/contact_item_name")[i].click()      
       sexname=numbe()      
       if sexname =="男":
         print(str(sexname))

else:
         print(str(sexname))

else:
       print(name_a)
       print("不存在")
   except:
     print("出错,跳过!")

综合:


// An highlighted block
# -*- encoding=utf8 -*-
__author__ = "liuqingsong"
def numbe():
 if exists(Template(r"tpl1574867500094.png", threshold=0.85, rgb=True, target_pos=0, record_pos=(0.779, 0.382), resolution=(960, 540))):
   sex = "女"  
 if exists(Template(r"tpl1574924960910.png", threshold=0.89, rgb=True, target_pos=5, record_pos=(0.779, 0.382), resolution=(960, 540))):
   sex = "男"
 else:
   sex = "不存在"
 namesex = sex
 keyevent("4")
 return namesex
def scoll():
 try:
   swipe(v1=(629, 1750),v2=(629, 310)) # 滑动距离需要根据手机分辨率自行调整        
 except:
   print("can't go back to the main page")

def number():  
 data_list =[]
 for i in range(9): # 根据手机分辨率自行调整
   try:
     title =poco(name="com.alipay.mobile.contactsapp:id/contact_item_name")[i].get_text()
     name = poco(name="com.alipay.mobile.contactsapp:id/concast_from")[i].get_text()
     print(title)
     name_a =name[5:6]
     if title not in data_list and name_a is not "1":
       poco("com.alipay.mobile.contactsapp:id/contact_item_name")[i].click()      
       sexname=numbe()      
       if sexname =="男":
         print(str(sexname))
         with open(r'./new/男.csv','a',encoding='utf-8') as f:
           f.write("{},{}\n".format(title,sexname))
       else:
         print(str(sexname))
         with open(r'./new/女.csv','a',encoding='utf-8') as f:
           f.write("{},{}\n".format(title,sexname))
     else:
       print(name_a)
       print("不存在")
   except:
     print("出错,跳过!")
a=0
while a<5:#根据手机上号码量的多少自行选择
 number()
 scoll()
 sleep(1)
 a=a+1

以上是用的是airtest实现的,效率不是很高,同样进行简单改动可以实现支付宝真实号码筛选,效率很高,偶尔使用一下还是可以的,切不可用于非法用途,大家有什么好的方式欢迎留言!

总结

以上所述是小编给大家介绍的Python实现手机号自动判断男女性别,希望对大家有所帮助!

来源:https://blog.csdn.net/qq_15687823/article/details/103645268

标签:Python,手机号,判断,男女,性别
0
投稿

猜你喜欢

  • 如何编写python的daemon程序

    2023-07-27 05:13:28
  • Python导入模块包原理及相关注意事项

    2023-01-26 04:46:31
  • python Matplotlib数据可视化(2):详解三大容器对象与常用设置

    2022-11-23 21:10:41
  • 解决Python 写文件报错TypeError的问题

    2022-09-18 06:54:26
  • 用javascript结合Cookies记录浏览历史

    2008-02-12 12:37:00
  • 15个短代码示例理解python丰富的编程思维

    2022-07-18 08:16:57
  • win7下 python3.6 安装opencv 和 opencv-contrib-python解决 cv2.xfeatures2d.SIFT_create() 的问题

    2022-03-31 17:26:15
  • 使用Dreamweaver便捷技巧方法十六则

    2010-07-02 16:28:00
  • Python学习笔记之装饰器

    2021-03-03 02:02:48
  • Python用K-means聚类算法进行客户分群的实现

    2022-04-03 23:35:18
  • 使用Python 统计文件夹内所有pdf页数的小工具

    2022-07-06 23:21:46
  • Python生成器定义与简单用法实例分析

    2021-03-12 21:45:59
  • python celery分布式任务队列的使用详解

    2021-04-22 18:17:56
  • python线程安全及多进程多线程实现方法详解

    2023-08-27 02:01:54
  • 使用python统计文件行数示例分享

    2022-08-22 22:49:38
  • python中argparse模块基础及使用步骤

    2023-01-26 19:21:59
  • python引入不同文件夹下的自定义模块方法

    2023-04-24 18:37:22
  • 一个不错的js+css二级分类菜单代码

    2007-12-28 21:22:00
  • 详解MySQL数据库中字符串的正确使用

    2010-06-20 15:01:00
  • pandas筛选某列出现编码错误的解决方法

    2021-10-18 02:48:05
  • asp之家 网络编程 m.aspxhome.com