| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import os
- from playwright.sync_api import sync_playwright
- from screeninfo import get_monitors
- def get_wallet_detail(wallet_address: str, page):
- # 定义输入框和按钮的选择器
- input_selector = '#root > div > div > div.min-h-screen.overflow-hidden.sm\\:ml-0 > div:nth-child(3) > div > div > div.flex.flex-col.space-y-4 > input'
- button_selector = '#root > div > div > div.min-h-screen.overflow-hidden.sm\\:ml-0 > div:nth-child(3) > div > div > div.flex.flex-col.space-y-4 > button.px-4.py-2.text-white.font-semibold.rounded-md.bg-purple-600.cursor-pointer.hover\\:bg-purple-700'
- try:
- # 等待输入框出现并确保其可交互
- page.wait_for_selector(input_selector, state='visible', timeout=10000)
- # 清除输入框内容(如果有默认值)
- page.fill(input_selector, '')
- # 填入钱包地址
- page.fill(input_selector, wallet_address)
- # 等待按钮出现并尝试点击,捕获异常以忽略找不到按钮的情况
- page.wait_for_selector(button_selector, state='visible', timeout=10000)
- try:
- page.click(button_selector)
- print(f"已成功点击按钮,查询钱包地址:{wallet_address}")
- except Exception as e:
- print(f"未找到按钮,跳过点击操作。钱包地址:{wallet_address}")
- except Exception as e:
- print(f"查询钱包 {wallet_address} 时出错: {str(e)}")
- def main():
- # 读取钱包地址
- wallet_list = []
- wallet_txt_path = os.path.join(os.getcwd(), "wallet.txt")
- with open(wallet_txt_path, "r") as file:
- wallet_list = [line.strip() for line in file]
- if len(wallet_list) == 0:
- print("未找到钱包地址,程序退出。")
- return
- if len(wallet_list) > 10:
- print("钱包地址数量超过10个,仅处理前10个。")
- wallet_list = wallet_list[:10]
- # 获取屏幕大小
- monitors = get_monitors()
- screen_width = monitors[0].width
- screen_height = monitors[0].height
- # 每个窗口的大小
- window_width = screen_width // 5
- window_height = screen_height // 2
- with sync_playwright() as p:
- browser = p.chromium.launch(headless=False, args=["--start-maximized"])
- for i, wallet in enumerate(wallet_list):
- # 计算窗口位置
- row = i // 5
- col = i % 5
- x = col * window_width
- y = row * window_height
- # 创建新页面并设置窗口位置
- context = browser.new_context()
- page = context.new_page()
- page.set_viewport_size({'width': window_width, 'height': window_height})
- page.context.set_window_position(x, y)
- page.goto("https://repute.monadscore.xyz/")
- print(f"已打开浏览器实例,查询钱包地址:{wallet}")
- get_wallet_detail(wallet, page)
- print("所有浏览器已打开,可以手动操作。")
- input("按任意键退出程序...")
- # 关闭浏览器
- browser.close()
- if __name__ == "__main__":
- main()
|