-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathig_poster.py
48 lines (46 loc) · 1.63 KB
/
ig_poster.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import subprocess
import osascript
import pyautogui
import time
def auto_post(caption):
# 1. OPEN SAFARI
subprocess.call(['open', '-a', 'Safari'])
# 2. NAVIGATE TO INSTAGRAM.COM
url = 'https://www.instagram.com'
osascript.osascript('tell application "Safari" to open location "{0}"'.format(url))
# 3. CLICK CREATE POST
time.sleep(4)
create_button = pyautogui.locateOnScreen('pyautogui_images/create_ig_post.png')
pyautogui.click(create_button)
time.sleep(2)
# 4. UPLOAD IMAGE
add_photo = pyautogui.locateOnScreen('pyautogui_images/add_photo.png')
pyautogui.click(add_photo)
time.sleep(2)
ig_photo = pyautogui.locateOnScreen('pyautogui_images/ig_photo.png')
pyautogui.click(ig_photo)
time.sleep(1)
upload_photo = pyautogui.locateOnScreen('pyautogui_images/upload_photo.png')
pyautogui.click(upload_photo)
time.sleep(5)
next_button = pyautogui.locateOnScreen('pyautogui_images/next_button.png')
pyautogui.click(next_button)
pyautogui.move(0, -50)
time.sleep(3)
next_button2 = pyautogui.locateOnScreen('pyautogui_images/next_button2.png')
pyautogui.click(next_button2)
time.sleep(3)
# 5. PASTE CAPTION
caption_space = pyautogui.locateOnScreen('pyautogui_images/caption_space.png')
pyautogui.click(caption_space)
time.sleep(1.5)
pyautogui.write(caption)
time.sleep(2)
# 6. POST
share_button = pyautogui.locateOnScreen('pyautogui_images/share_button.png')
pyautogui.click(share_button)
# 7. Mimimize Safari
time.sleep(3)
pyautogui.hotkey('command', 'm')
if __name__ =='__main__':
auto_post('AI is lit AF.')