diff --git a/main.py b/main.py index 9137b20..8420532 100644 --- a/main.py +++ b/main.py @@ -25,37 +25,34 @@ def __init__(self, username, pw): def get_unfollowers(self): self.driver.find_element_by_xpath("//a[contains(@href,'/{}')]".format(self.username))\ - .click() + .click() sleep(2) self.driver.find_element_by_xpath("//a[contains(@href,'/following')]")\ - .click() + .click() following = self._get_names() self.driver.find_element_by_xpath("//a[contains(@href,'/followers')]")\ - .click() + .click() followers = self._get_names() not_following_back = [user for user in following if user not in followers] - print(not_following_back) + for x in not_following_back : + print(x) def _get_names(self): - sleep(2) - sugs = self.driver.find_element_by_xpath('//h4[contains(text(), Suggestions)]') - self.driver.execute_script('arguments[0].scrollIntoView()', sugs) - sleep(2) - scroll_box = self.driver.find_element_by_xpath("/html/body/div[3]/div/div[2]") + scroll_box = self.driver.find_element_by_xpath("/html/body/div[4]/div/div[2]") last_ht, ht = 0, 1 while last_ht != ht: last_ht = ht sleep(1) - ht = self.driver.execute_script(""" - arguments[0].scrollTo(0, arguments[0].scrollHeight); - return arguments[0].scrollHeight; - """, scroll_box) + ht = self.driver.execute_script("""arguments[0] + .scrollTo(0, arguments[0].scrollHeight); + return arguments[0].scrollHeight; + """, scroll_box) links = scroll_box.find_elements_by_tag_name('a') names = [name.text for name in links if name.text != ''] # close button - self.driver.find_element_by_xpath("/html/body/div[3]/div/div[1]/div/div[2]/button")\ - .click() + self.driver.find_element_by_xpath("/html/body/div[4]/div/div[1]/div/div[2]/button").click() return names + my_bot = InstaBot('_aaronjack', pw)