铁雪资源网 Design By www.gsvan.com

python 通过手机号识别出对应的微信性别,具体代码如下所述:

def getGender(self,tel):
  self.d(resourceId="com.tencent.mm:id/kh").clear_text()
  self.d(resourceId="com.tencent.mm:id/kh").set_text(tel)    
  self.d(resourceId="com.tencent.mm:id/mf").click()        
  time.sleep(1)
  self.d.watcher("AccNotExist").when(text="该用户不存在").click(resourceId="com.tencent.mm:id/kd")
  self.d.watcher("AccException").when(text="被搜帐号状态异常,无法显示").click(resourceId="com.tencent.mm:id/kd"
  self.d.watchers.run()
  AccNotExist = self.d.watcher("AccNotExist").triggered
  AccException = self.d.watcher("AccException").triggered
  OperationFrequently = self.d.watcher("OperationFrequently").triggered
  if AccNotExist:
   self.d.watchers.reset()
   return "用户不存在"
  elif AccException:
   self.d.watchers.reset()
   return "被搜帐号状态异常,无法显示"
  elif OperationFrequently:
   self.d.watchers.reset()
  if self.d(resourceId="com.tencent.mm:id/b3y").exists:
   gender = self.d(resourceId="com.tencent.mm:id/b3y").info['contentDescription']
   self.d(resourceId="com.tencent.mm:id/kb").click() # back
   return gender
  else:
   self.d(resourceId="com.tencent.mm:id/kb").click() # back
   return "用户未设置性别"
def write_excel_xls(self,pathfile, value):
  index = len(value) 
  workbook = xlwt.Workbook() # 新建一个工作簿
  sheet1 = workbook.add_sheet("boy") # 在工作簿中新建一个表格
  sheet2 = workbook.add_sheet("girl")
  sheet3 = workbook.add_sheet("NotSet")
  sheet4 = workbook.add_sheet("NotExist")
  sheet5 = workbook.add_sheet("AccountE")
  def writesheet(self,sheet):
   for i in range(0, index):
     for j in range(0, len(value[i])):
      sheet.write(i, j, value[i][j]) # 像表格中写入数据(对应的行和列)
   workbook.save(pathfile) # 保存工作簿
  writesheet(self,sheet1)
  writesheet(self,sheet2)
  writesheet(self,sheet3)
  writesheet(self,sheet4)
  writesheet(self,sheet5)
def write_excel_xls_append(self,pathfile, sheet_name, value):
  index = len(value) # 获取需要写入数据的行数
  workbook = xlrd.open_workbook(pathfile) # 打开工作簿
  # sheets = workbook.sheet_names() # 获取工作簿中的所有表格
  worksheet = workbook.sheet_by_name(sheet_name) # 获取工作簿中所有表格中的的第一个表格
  rows_old = worksheet.nrows # 获取表格中已存在的数据的行数
  new_workbook = copy(workbook) # 将xlrd对象拷贝转化为xlwt对象
  new_worksheet = new_workbook.get_sheet(sheet_name) # 获取转化后工作簿中的第一个表格
  for i in range(0, index):
   for j in range(0, len(value[i])):
     new_worksheet.write(i + rows_old, j, value[i][j]) # 追加写入数据,注意是从i+rows_old行开始写入
  new_workbook.save(pathfile) # 保存工作簿
  # print("%s【追加】写入数据成功!" % pathfile)
 
def read_excel_xls(self,pathfile, sheet_name):
  workbook = xlrd.open_workbook(pathfile) # 打开工作簿
  sheets = workbook.sheet_names() # 获取工作簿中的所有表格
  worksheet = workbook.sheet_by_name(sheet_name) # 获取工作簿中所有表格中的的第一个表格
  for i in range(0, worksheet.nrows):
   for j in range(0, worksheet.ncols):
     print(worksheet.cell_value(i, j), "\t", end="") # 逐行逐列读取数据

ps:下面看下python 通过电话号码获取微信性别信息

getWeixinPro.py

# coding:utf-8
import sys,re,xlrd
from xlwt import *
reload(sys)
sys.setdefaultencoding('utf8')
from uiautomator import device as d
import unittest
import time
#打开excel
def openExcel(file):
  try:
    data = xlrd.open_workbook(file)
    return data
  except Exception as e:
    print (str(e))
def floatToInt(list):
  realList = []
  for value in list:
    if (type(value) == float):
      value = str(value)
      value = re.sub('\.0*$', "", value)
    value = str(value).rstrip()
    realList.append(value)
  return realList
class Mytest(unittest.TestCase):
  #初始化工作
  def setUp(self):
    print ("--------------初始化工作")
  #退出清理工作
  # def tearDown(self):
  #   print ("--------------退出清理工作")
  #测试
  def test_33(self):
    # d.screen.on()
    file='1.xlsx'
    print("check[+] %s" % file)
    data = openExcel(file)
    sheets = data.sheets()
    table=sheets[0]
    writeFile = Workbook(encoding='utf-8')
    # 指定file以utf-8的格式打开
    writeTable = writeFile.add_sheet('微信号-性别')
    for row in range(table.nrows):
      tel=floatToInt(table.row_values(row))[0]
      if not d(resourceId="com.tencent.mm:id/h2").exists:
        if d(resourceId='com.tencent.mm:id/h7').exists:
          d(resourceId='com.tencent.mm:id/h7').click()
      if d(resourceId="com.tencent.mm:id/h2").exists:
        d(resourceId="com.tencent.mm:id/h2").clear_text()
        d(resourceId="com.tencent.mm:id/h2").set_text(tel)
        d(resourceId='com.tencent.mm:id/b20').click()
        d.watcher(tel).when(resourceId="com.tencent.mm:id/aes").when(text="确定")           .click(text="确定")
        d.watchers.run()
        isTriggered=d.watcher(tel).triggered
        print(isTriggered)
        if isTriggered:
          d.watcher(tel).remove()
        if not isTriggered:
          if d(resourceId='com.tencent.mm:id/agf').exists:
            contentDescription=d(resourceId='com.tencent.mm:id/agf').info['contentDescription']
            print("tel=%s,sex=%s"%(tel,contentDescription))
            writeTable.write(row, 0, tel)
            writeTable.write(row, 1, contentDescription)
          else:
            print("tel=%s,sex=%s" % (tel,"用户没有设置性别"))
            writeTable.write(row, 0, tel)
            writeTable.write(row, 1, "用户没有设置性别")
          if d(resourceId='com.tencent.mm:id/h7').exists:
            d(resourceId='com.tencent.mm:id/h7').click()
        else:
          print("tel=%s,sex=%s" % (tel, "没有该用户"))
          writeTable.write(row, 0, tel)
          writeTable.write(row, 1, "没有该用户")
      time.sleep(3)
    writeFile.save('wx_tel_sex.xlsx')
    print ("--------------测试1")
if __name__ == '__main__':
  # from uiautomator import device as d
  #
  #
  # print(d.info)
  #
  # d.press.power()
  unittest.main()

总结

以上所述是小编给大家介绍的python 通过手机号识别出对应的微信性别,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

标签:
python,手机号识别,python手机号微信性别

铁雪资源网 Design By www.gsvan.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
铁雪资源网 Design By www.gsvan.com

评论“python 通过手机号识别出对应的微信性别(实例代码)”

暂无python 通过手机号识别出对应的微信性别(实例代码)的评论...

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。