instapy 2021 code example

Example: instapy 2021

1from time import sleep
 2from selenium import webdriver
 3
 4browser = webdriver.Firefox()
 5browser.implicitly_wait(5)
 6
 7browser.get('https://www.instagram.com/')
 8
 9login_link = browser.find_element_by_xpath("//a[text()='Log in']")
10login_link.click()
11
12sleep(2)
13
14username_input = browser.find_element_by_css_selector("input[name='username']")
15password_input = browser.find_element_by_css_selector("input[name='password']")
16
17username_input.send_keys("<your username>")
18password_input.send_keys("<your password>")
19
20login_button = browser.find_element_by_xpath("//button[@type='submit']")
21login_button.click()
22
23sleep(5)
24
25browser.close()