Last active
January 18, 2022 13:47
-
-
Save itherunder/2c552e820107c583042f7605b62d53ea to your computer and use it in GitHub Desktop.
`Monaco` 自动`follow` 脚本,`Python`,记得`pip3 install pyautogui`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyautogui, time, random, sys, os | |
def send_email(msg): | |
msg = msg.replace(' ', '_') | |
os.system('send_mail.exe %s' % msg) | |
def into_followers(): | |
loc = pyautogui.locateCenterOnScreen("followers.png", confidence=0.9) | |
while loc is None: | |
print('[INFO] Cannot find followers.') | |
time.sleep(1) | |
loc = pyautogui.locateCenterOnScreen("followers.png", confidence=0.9) | |
pyautogui.click(loc.x, loc.y, clicks=1, interval=0.2, duration=0.2, button='left') | |
def next_user(): | |
pyautogui.scroll(2000) | |
time.sleep(2) | |
loc = pyautogui.locateCenterOnScreen('unfollow.png', confidence=0.9) | |
if loc is None: | |
print('[ERROR] Cannot find unfollow.') | |
send_email('[ERROR] Cannot find unfollow.') | |
sys.exit(1) | |
pyautogui.click(loc.x-100, loc.y-9, clicks=1, interval=0.2, duration=0.2, button='left') | |
time.sleep(2) | |
loc = pyautogui.locateCenterOnScreen('nft.png', confidence=0.8) | |
if loc is None: | |
loc = pyautogui.locateCenterOnScreen('post.png', confidence=0.8) | |
if loc is None: | |
pyautogui.scroll(-random.randint(100, 500) if random.randint(1,10) % 2 == 1 else random.randint(100, 500)) | |
next_user() | |
loc = pyautogui.locateCenterOnScreen('followers.png', confidence=0.8) | |
pyautogui.click(loc.x, loc.y, clicks=1, interval=0.2, duration=0.2, button='left') | |
def click_follow(): | |
scroll_time, click_time = 0, 0 | |
while True: | |
loc = pyautogui.locateCenterOnScreen('follow.png', confidence=0.9) | |
if loc is None: | |
if scroll_time == 2: # 滚到底了,下一个 | |
next_user() | |
scroll_time = 0 | |
continue | |
pyautogui.scroll(-800) | |
scroll_time += 1 | |
print('[INFO] Next page.') | |
time.sleep(1) | |
continue | |
pyautogui.click(loc.x, loc.y, clicks=1, interval=0.2, duration=0.2, button='left') | |
click_time += 1 | |
if click_time % 50 == 0: | |
send_email('[INFO] You have followed %d users.' % click_time) | |
time.sleep(random.randint(10, 13)) | |
try: | |
click_follow() | |
except Exception as e: | |
print(e) | |
send_email(str(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment