コード例 #1
0
def new_session(instagram: Instagram, utils: Utils) -> Dict[str, set]:
    """Asks for an instagram account and number of followers. Then, visits
    the account and return the amount of followers in a set.

    Note: It avoids accounts that we already follow"""

    new_user = input(
        "Write the username from where you want to get the followers: ")
    amount = input("Write the amount of followers to get: ")
    amount = int(amount)

    following = utils.select_followees("Following", instagram.username)
    visited = utils.select_followees("Visited", instagram.username)

    union = following.union(visited)

    print("Getting new accounts, please wait...")
    users_left = instagram.get_followers(new_user, amount)
    users_left = users_left.difference(union)

    print(f"{len(users_left)} to check")

    pending_users_left = dict()
    pending_users_left[instagram.username] = users_left

    return pending_users_left
コード例 #2
0
    # Login
    utils = Utils(cursor)
    instagram = Instagram(username, password, driver)

    # Wait for login
    time.sleep(3)
    print("Login done")

    del password

    if new_account(instagram, utils):
        utils.insert_user(username)
        print("Getting accounts, please wait...")

        followers = instagram.get_followers(username)
        followees = instagram.get_followees(username)

        save_true_followers(instagram, utils, followers, followees)

        # Unfollow accounts that don't follow back
        unfollow_left = followees.difference(followers)
        pending_unfollows: Dict[str, set] = dict()
        pending_unfollows[instagram.username] = unfollow_left

        print(f"{len(unfollow_left)} accounts of {len(followees)} to unfollow")
        unfollow(instagram, utils, pending_unfollows)

        # Needed for next step
        pending_unfollows[instagram.username] = set()
        pending_users_left: Dict[str, set] = dict()