Beispiel #1
0
    def followings(self):
        z = 0
        self.to_profile()
        x = 0
        # Below finds the following subtag in the users profile page
        try:
            following_sub = WebDriverWait(DRIVER, 3).until(
                ec.presence_of_element_located(
                    (By.PARTIAL_LINK_TEXT, "following")))
        except TimeoutException:
            try:
                DRIVER.find_element_by_css_selector(
                    'button._5f5mN.-fzfL._6VtSN.yZn4P')
                return
            except NoSuchElementException:
                raise RuntimeError(
                    "If you are logged in and recieving this error, you'll need to manually log into Instagram as your account has been flagged for suspicious behavior.  Otherwise, you'll need to call the login function."
                )

        following_count = following_sub.__getattribute__('text')
        following_count = int(re.search(r'\d+', following_count).group())
        use_following_count = following_count / 12
        following_sub.click()
        bottom = WebDriverWait(DRIVER, 3).until(
            ec.presence_of_element_located(
                (By.CSS_SELECTOR, 'div.PdwC2.HYpXt')))
        while x < use_following_count:
            while z < 6:
                actions = webdriver.ActionChains(DRIVER)
                actions.move_to_element(bottom)
                actions.click()
                actions.send_keys(Keys.END)
                actions.perform()
            x += 1