对于我的第一个自动化项目,我正在开发一个机器人,该机器人可以转到instagram上的主题标签,并像遍历它们的每个图片一样对其进行操作。该机器人可以执行上面提到的操作,除了像迭代每个图片一样。我需要帮助弄清楚这一点。
i
import pyautogui,time
pyautogui.FAILSAFE = False
pyautogui.moveTo(608, 431,duration=0.1) #Goes moves cursor to search bar
pyautogui.click(608, 43) # clicks on search bar
pyautogui.typewrite("http://instagram.com") #types in web address
pyautogui.typewrite(["enter"]) #activates enter key
pyautogui.moveTo(641, 96,duration=0.1) #moves cursor to instagram search bar
pyautogui.click(641, 96) #clicks on search bar
pyautogui.typewrite("#cats")# types in hashtag
pyautogui.moveTo(652, 225,duration=0.1) #moves cursor to hashtag suggestion
time.sleep(1);pyautogui.click(652, 225)#clicks on hashtag suggestion
#Clicks on picture
pyautogui.moveTo(348, 564,duration=0.1) #moves cursor on picture
time.sleep(1);pyautogui.click() #Clicks on picture
time.sleep(1);pyautogui.moveTo(1170, 451) #moves cursor to the right arrow on picture
for i in range(4): #clicks on pictures by iterating a certain number of times
pyautogui.click(1170, 451)
答案 0 :(得分:1)
尝试添加以下内容
for i in range(4):
time.sleep(5)
pyautogui.moveTo(xRes/2, yRes/2, duration=0.5)
pyautogui.doubleClick()
xRes
和yRes
指的是显示器的分辨率,就像双击图像一样。希望对您有帮助