You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.4 KiB
66 lines
2.4 KiB
import os
|
|
from playwright.sync_api import sync_playwright
|
|
import time
|
|
|
|
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 run():
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(
|
|
headless=True,
|
|
args=["--start-maximized"]
|
|
)
|
|
|
|
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
|
|
|
|
context = browser.new_context(no_viewport=True)
|
|
|
|
for i, wallet in enumerate(wallet_list, 1):
|
|
page = context.new_page()
|
|
page.goto("https://repute.monadscore.xyz/")
|
|
print(f"已打开第 {i} 个标签页")
|
|
time.sleep(1)
|
|
print(f'正在查询钱包 {i} : {wallet}')
|
|
get_wallet_detail(wallet, page)
|
|
|
|
time.sleep(3600)
|
|
|
|
context.close()
|
|
browser.close()
|
|
|
|
|
|
def main():
|
|
while True:
|
|
run()
|
|
time.sleep(5)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|