• 1000 ------------------- код ------------------------------ ---------
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class InstagramBot():
def __init__(self, email, password):
self.browserProfile = webdriver.ChromeOptions()
self.browserProfile.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
self.browser =webdriver.Chrome('chromedriver.exe',chrome_options=self.browserProfile)
self.email = email
self.password = password
def unfollowWithUsername(self, username):
self.browser.get('https://www.instagram.com/' + username + '/')
time.sleep(2)
followButton = self.browser.find_element_by_css_selector('button')
if (followButton.text == 'Following' or followButton.text == 'Message' ):
followButton.click()
time.sleep(2)
confirmButton = self.browser.find_element_by_xpath('//button[text() = "Unfollow"]')
confirmButton.click()
else:
print("You are not following this user")
основная проблема в строках ниже
followButton = self.browser.find_element_by_css_selector('button')
if (followButton.text == 'Following' or followButton.text == 'Message' ):
followButton.click()