快手 滑动

import uiautomator2 as u2
import time,sys,emoji,pymysql,random
import logging,datetime
import re
import json
from string import Template
from func_timeout import FunctionTimedOut, func_timeout

def charu(uuk):
    con = connect.cursor()
##    con.executemany('insert ignore into xinxizl(zhiwei,gongsi,gongsitag,gongzi,niangongzi,diqu,xueli,jingyan,rq,wz,gslx,gsrs,leibie)values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',
##                        (i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9],i[10],i[11],i[12]))
    try:
        con.executemany('replace into xianyu1(mc,sm,jg,xy,maif,gjz)values(%s,%s,%s,%s,%s,%s)',uuk)
        connect.commit()
        print("保存数据成功")
    except Exception as e:
        connect.rollback()
def jiance():
    d = u2.connect('4d34abc3')
    #d.click_post_delay = 1.5#
    if not d.info.get('screenOn'):
        d.press("power") 
        time.sleep(4)
        d.unlock()
    time.sleep(5)
    if d(text="搜索").exists(timeout=5):#判断程序是否打开
        return 1
    if d(text="电话").exists(timeout=5):
        d.app_start("com.taobao.idlefish")#打开程序
        time.sleep(5)
        if d(text="搜索").exists(timeout=5):#判断程序是否打开
            #logger.info("已打开程序")
            return 2

d = u2.connect('4d34abc3')#pvq4nrx4kzemw4ca  '4d34abc3'
#au=d.app_start("com.taobao.idlefish")#打开程序
au=d.app_start("com.kuaishou.nebula")#打开程序

#time.sleep(12)
while 1:
    #d.swipe_ext("up", 0.7)
    d.drag(300,700,300,100,0.1)
    time.sleep(random.randint(9,21))
    print(datetime.datetime.now().strftime('%H:%M:%S'))
    #time.sleep(13)
    continue
    am1=d.xpath('//*[@resource-id="com.taobao.idlefish:id/rv_main_container"]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.support.v7.widget.RecyclerView[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.support.v7.widget.RecyclerView[1]').all()
    am2=d.xpath('//*[@resource-id="com.taobao.idlefish:id/rv_main_container"]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.support.v7.widget.RecyclerView[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.support.v7.widget.RecyclerView[1]').all()
    am3=d.xpath('//*[@resource-id="com.taobao.idlefish:id/rv_home_second_tab"]').all()
    hxxz=d.xpath('//*[@resource-id="com.taobao.idlefish:id/tab_item_selector2"]').all()
    print(am3)
    for a1 in am3:
        a2=a1.elem.getchildren()
        for a3 in a2:
            a4=a3.getchildren()
            for a5 in a4:
                a6=a5.getchildren()
                for a7 in a6:
                    a8=a7.getchildren()
                    for a9 in a8:
                        a10=a9.get("text")
                        if a10!="":
                            print(a8,a10)
    sys.exit(0)
    print(am1)
    print(am2)
    if am1:
        am=am1
    else:
        if am2:
            am=am2
    #elements = d.xpath('//*[@clickable="true"]').all()
    if not am:
        d = u2.connect('4d34abc3')#pvq4nrx4kzemw4ca  '4d34abc3'
        au=d.app_start("com.taobao.idlefish")#打开程序
        time.sleep(12)
    a=0
    for ele in am:
        children = ele.elem.getchildren()
        for child in children:
            child2 = child.getchildren()
            for a2 in child2:
                a3=a2.getchildren()
                for a4 in a3:
                    a5=a4.getchildren()
                    lba=[]
                    result=[]
                    mc=""
                    js=""
                    jg=""
                    xy=""
                    mf=""
                    for a6 in a5:
                        a66=a6.get("text").replace("pic","").replace(" ","").replace('\n','')
                        if a66!="" and a66!="pic":
                            lba.append((3,a66))
                        a7=a6.getchildren()
                        try:
                            for a8 in a7:
                                a88=a8.get("text").replace('¥','').replace('\n','')
                                if a88!="":
                                    lba.append((4,a88))
                        except:
                            continue
                    #print(lba)
                    #print(type(lb[0][0]))
                    if len(lba)==5:
                        if lba[0][0]==3 and lba[1][0]==3 and lba[2][0]==4 and lba[3][0]==3 and lba[4][0]==3:
                            print(lba)
                            mc=lba[0][1]
                            js=lba[1][1]
                            jg=lba[2][1]
                            xy=lba[3][1]
                            mf=lba[4][1]
                        if lba[0][0]==3 and lba[1][0]==4 and lba[2][0]==4 and lba[3][0]==3 and lba[4][0]==3:
                            print(lba)
                            mc=lba[0][1]
                            js=""
                            jg=lba[1][1]+lba[2][1]
                            xy=lba[3][1]
                            mf=lba[4][1]
                    else:
                        if len(lba)==6:
                            if lba[0][0]==3 and lba[1][0]==3 and lba[2][0]==4 and lba[3][0]==4 and lba[4][0]==3 and lba[5][0]==3:
                                print(lba)
                                mc=lba[0][1]
                                js=lba[1][1]
                                jg=lba[2][1]+lba[3][1]
                                xy=lba[4][1]
                                mf=lba[5][1]
                    if mc!="" and jg!="" and xy!="" and mf!="":
                        result.append(([mc,js,jg,xy,mf,"儿童轮滑",]))
                        charu(result)
                        
                    
                    
             
    print("############################################")

 

d.click(85,380)

qiandao=d.xpath('//*[@text="去签到"]')
>>> qiandao.click()
kansp=d.xpath('//*[@text="去赚钱"]')
>>> kansp.click()
baox=d.xpath('//*[@resource-id="activity-181"]')
>>> kansp.click()

 d.swipe(800,1500,800,200)

 

d = u2.connect('4d34abc3')#pvq4nrx4kzemw4ca  '4d34abc3'
#au=d.app_start("com.taobao.idlefish")#打开程序
au=d.app_start("com.kuaishou.nebula")#打开程序

#time.sleep(12)
ab=0
while 1:
    ab=ab+1
    #d.swipe_ext("up", 0.7)
    #d.drag(300,1300,300,500,0.1)
    d.swipe(800,1500,800,200)
    time.sleep(2)
    if ab%5==0:
        d.click(1000,940)
    if ab%6==0:
        d.click(1000,820)
    time.sleep(random.randint(9,31))
    
    print(datetime.datetime.now().strftime('%H:%M:%S'))

 

posted @ 2022-05-04 12:37  myrj  阅读(104)  评论(0编辑  收藏  举报