Python實現(xiàn)手機號自動判斷男女性別(實例解析)
本文性別判斷主要依靠airtest中的自動化測試實現(xiàn)
通過自動對比支付寶頁面男女圖像,從而實現(xiàn)男女判斷
代碼如下:
男女判斷函數(shù):
// 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 手機滑動(根據(jù)手機分辨率自行調(diào)整): // An highlighted block def scoll(): try: swipe(v1=(629, 1750),v2=(629, 310)) # 滑動距離需要根據(jù)手機分辨率自行調(diào)整 except: print("can't go back to the main page")
刷選函數(shù):
// An highlighted block def number(): data_list =[] for i in range(9): # 根據(jù)手機分辨率自行調(diào)整 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)) # 滑動距離需要根據(jù)手機分辨率自行調(diào)整 except: print("can't go back to the main page") def number(): data_list =[] for i in range(9): # 根據(jù)手機分辨率自行調(diào)整 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:#根據(jù)手機上號碼量的多少自行選擇 number() scoll() sleep(1) a=a+1
以上是用的是airtest實現(xiàn)的,效率不是很高,同樣進行簡單改動可以實現(xiàn)支付寶真實號碼篩選,效率很高,偶爾使用一下還是可以的,切不可用于非法用途,大家有什么好的方式歡迎留言!
總結(jié)
以上所述是小編給大家介紹的Python實現(xiàn)手機號自動判斷男女性別,希望對大家有所幫助!
相關文章
python數(shù)據(jù)類型bytes?和?bytearray的使用與區(qū)別
本文主要介紹了python數(shù)據(jù)類型bytes?和?bytearray的使用與區(qū)別,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-02-02在Sublime Editor中配置Python環(huán)境的詳細教程
這篇文章主要介紹在sublime編輯器中安裝python軟件包,以 實現(xiàn)自動完成等功能,并在sublime編輯器本身中運行build,本文通過實例代碼給大家介紹的非常詳細,需要的朋友參考下吧2020-05-05通過Python模塊filecmp 對文件比較的實現(xiàn)方法
這篇文章主要介紹了通過Python模塊filecmp 對文件比較的實現(xiàn)方法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2018-06-06對django 模型 unique together的示例講解
今天小編就為大家分享一篇對django 模型 unique together的示例講解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-08-08