1from selenium import webdriver
2from selenium.webdriver.common.keys import Keys
3from time import sleep
4
5class InstagramBot:
6 def __init__(self, username, password):
7 self.username = username
8 self.password = password
9 self.driver = webdriver.Chrome('C:\Program Files (x86)\chromedriver.exe')
10
11 def CloseBrowser(self):
12 self.driver.close
13
14 def Login(self):
15 driver = self.driver
16 driver.get('https://instagram.com/')
17 sleep(1)
18 username_input = driver.find_element_by_xpath('//input[@name="username"]')
19 username_input.send_keys(self.username)
20 sleep(2)
21 password_input = driver.find_element_by_xpath('//input[@name="password"]')
22 password_input.send_keys(self.password)
23 sleep(1)
24 button = driver.find_element_by_xpath('//button[@type="submit"]')
25 button.click()
26
27
28bot1 = InstagramBot()
29bot1.Login()
30