bigget_nft領取指令碼

冷光清坠落發表於2024-03-15
# coding: utf-8#
import uiautomator2 as u2
import time
from tqdm import tqdm
from loguru import logger

def xpath是否存在(xpath,timeout=30):
    for index in range(0,timeout):
        wallet_ele = d.xpath(xpath).exists
        if(wallet_ele):
            logger.success(f"xpath已找到:{xpath}")
            return True
        else:
            logger.debug(f"xpath未找到 {xpath} 等待:{index}")
            time.sleep(1)
    logger.error(f"xpath等待超時:{xpath}是否存在")
    return False
def 領取nft():
    time.sleep(2)
    d(description="首頁").click()
    time.sleep(2)
    d(description="賺幣中心").click()
    #d.xpath('//*[contains(@content-desc, "新人任務")]').click()
    time.sleep(3)
    d(scrollable=True).scroll.toEnd()
    time.sleep(2)
    d.click(0.806, 0.413)
    d(scrollable=True).scroll.toEnd()

    d.xpath('//*[contains(@content-desc, "SecondLive")]//android.view.View[1]').click()
    d(description="以後再說").click_exists()
    claim = xpath是否存在('//*[@content-desc="SecondLive"]')
    if claim:
        d.click(0.501, 0.874)
        time.sleep(5)

def click_5s(xpath,timeout=10):
    for index in range(0,timeout):
        wallet_ele = d.xpath(xpath).exists
        if(wallet_ele):
            d.xpath(xpath).click()
            logger.success("成功點選")
            return True
        else:
            logger.debug(f"xpath未找到 {xpath} 等待:{index}")
            time.sleep(1)
    logger.error("點選失敗")
    return False



def 新增私鑰(privatekey):
    d.app_start("com.bitkeep.wallet", use_monkey=True)
    d(description="暫不開啟").click_exists()
    time.sleep(10)
    #d(description="錢包").click()
    #d.xpath('//*[contains(@content-desc, "我")]/android.widget.ImageView[1]').click()
    click_5s('//*[contains(@content-desc, "錢") and contains(@content-desc, "包") and contains(@content-desc, "我")]/android.widget.ImageView[1]')
    d(description="新增錢包").click()
    d(description="助記詞/私鑰錢包\n支援12位、24位助記詞匯入或私鑰匯入").click()
    for index in range(0, 6):
        d(description="0").click()
    time.sleep(5)
    click_5s('//android.widget.EditText')
    time.sleep(2)
    d.send_keys(privatekey, True)
    #d.set_fastinput_ime(False)
    time.sleep(2)
    d(description="確認匯入").click()
    #d(scrollable=True).scroll.to(description="Polygon")
    d.xpath('//*[@content-desc="Polygon"]').click()
    d(description="確認").click()
    try:
        d(description="開始探索").click()
    except:
        pass
    return True
if __name__ == '__main__':
    d = u2.connect("22b4097f")
    d.set_fastinput_ime(True)

    print(d.info)
    #領取nft()

    acc_list =[]
    with open("address.txt","r") as f:
        lines = f.readlines()[300:]
    bar = tqdm(total = len(lines))
    for line in lines:
            line = line.replace("\n","")
            addr,key = line.split("----")
            acc = {
                "private_key": key,
                "address": addr
            }
            acc_list.append(acc)
    for acc in acc_list:
        try:
            add_status = 新增私鑰(acc['private_key'])
            if add_status:
                領取nft()
                logger.success(f"{acc['address']}領取nft成功!!!")
                d.app_stop("com.bitkeep.wallet")
                bar.update(1)
        except BaseException as e:
            logger.error(f"{acc['address']}領取nft失敗!!! ---- {e}")
        finally:
            try:
                d.app_stop("com.bitkeep.wallet")
            except:
                pass


# 檢查元素是否可點選

  

相關文章