I am working on a automatic instagram follower bot. It is a exercise from the 100 days of code on Udemy.
I have a problem with the element. I cant find the followertag.
I use the following code:
def find_follower(self):
time.sleep(2)
self.driver.get(f"https://www.instagram.com/{SIMILAR_ACCOUNT}")
time.sleep(2)
path = self.driver.find_element(by=By.CLASS_NAME, value="_aa_c")
print(path.text)
this_is_what_I_want = self.driver.find_elements(by=By.XPATH, value="//a[@href]")
for item in next2:
element = item.find_element(by=By.TAG_NAME, value="span").get_attribute("_ac2a _ac2b").click()
I want to push the follower link. I know the code is wrong. I tried so many tags but nothing works.
Does someone has any idea? Thank you very much
Best regards
Levin
CodePudding user response:
To click the "followers" button try this:
self.driver.find_elements(By.CSS_SELECTOR, "a[href*='followers']").click()
Or if you prefer XPath
self.driver.find_elements(By.XPATH, "//a[contains(@href,'followers')]").click()