import pyautogui
import time
import pyperclip
import pandas as pd
from tqdm import tqdm
import os
"""
the scripts is used for collect https://www.hbinghost.com/bitpay coin address.
"""
wallets = []
save_interval = 10
times = 999
pbar = tqdm(total=times, leave=True)
i = 0
coin_type = ['btc','usdt','ltc','doge']
coin_type = coin_type[0] # change the value
while i < times:
# 1. find the coin
while True:
location_coin = pyautogui.locateCenterOnScreen(os.path.join('img', coin_type+'.png'), confidence=0.9)
if location_coin is not None:
pyautogui.click(location_coin.x, location_coin.y, clicks=1, interval=0.2, duration=0.2, button="left")
time.sleep(0.1)
break
print("未找到coin图片,0.1秒后重试")
time.sleep(0.1)
# 2. copy coin address
while True:
location_ad = pyautogui.locateCenterOnScreen(os.path.join('img', coin_type+'_ad.png'), confidence=0.9)
if location_ad is not None:
pyautogui.moveTo(location_ad.x, location_ad.y+20)
time.sleep(0.1)
pyautogui.doubleClick()
time.sleep(0.1)
# pyautogui.hotkey('ctrl', 'c') not work
pyautogui.keyDown('ctrl')
pyautogui.press('c')
pyautogui.keyUp('ctrl')
time.sleep(0.1)
btc_address = pyperclip.paste()
wallets.append(btc_address)
break
print("未找到address图片,0.1秒后重试")
time.sleep(0.1)
# 3. save the address checkpoint
if i % save_interval == 1 or i == times-1:
print(wallets)
df = pd.DataFrame(wallets, columns=[coin_type+"_address"])
df.to_csv(coin_type+".csv")
# 4. refresh the page
while True:
location_re =pyautogui.locateCenterOnScreen(os.path.join('img', 'refresh.png'), confidence=0.9)
if location_re is not None:
pyautogui.click(location_re.x, location_re.y, clicks=1, interval=0.2, duration=0.2, button="left")
while True:
location_c = pyautogui.locateCenterOnScreen(os.path.join('img', 'continue.png'), confidence=0.9)
if location_c is not None:
pyautogui.click(location_c.x, location_c.y, clicks=1, interval=0.2, duration=0.2, button="left")
break
print("未找到continue图片,0.1秒后重试")
time.sleep(0.1)
i += 1
pbar.update(1)
break
print("未找到refresh图片,0.1秒后重试")
time.sleep(0.1)
打赏作者