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