def authenticate(self, username, password):
"""Log in to Instagram with the provided credentials."""
print('\nLogging in…')
self.driver.get('https://www.instagram.com')
# Go to log in
login_link = WebDriverWait(self.driver, 5).until(
EC.presence_of_element_located((By.LINK_TEXT, 'Log in'))
)
login_link.click()
# Authenticate
username_input = self.driver.find_element_by_xpath(
'//input[@placeholder="Username"]'
)
password_input = self.driver.find_element_by_xpath(
'//input[@placeholder="Password"]'
)
username_input.send_keys(username)
password_input.send_keys(password)
password_input.send_keys(Keys.RETURN)
time.sleep(1)
评论列表
文章目录