How to use the instapy.util.web_address_navigator function in instapy

To help you get started, we’ve selected a few instapy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Instagram-Tools / bot / instapy / unfollow_util.py View on Github external
follow_button_XP = read_xpath(get_following_status.__name__, "follow_button_XP")
    failure_msg = "--> Unable to detect the following status of '{}'!"
    user_inaccessible_msg = (
        "Couldn't access the profile page of '{}'!\t~might have changed the"
        " username".format(person)
    )
    # check if the page is available
    valid_page = is_page_available(browser, logger)
    if not valid_page:
        logger.warning(user_inaccessible_msg)
        person_new = verify_username_by_id(
            browser, username, person, None, logger, logfolder
        )
        if person_new:
            web_address_navigator(browser, ig_homepage + person_new)
            valid_page = is_page_available(browser, logger)
            if not valid_page:
                logger.error(failure_msg.format(person_new.encode("utf-8")))
                return "UNAVAILABLE", None

        else:
            logger.error(failure_msg.format(person.encode("utf-8")))
            return "UNAVAILABLE", None
    # wait until the follow button is located and visible, then get it
    try:
        browser.find_element_by_xpath(
            read_xpath(get_following_status.__name__, "follow_button_XP")
        )
        follow_button_XP = read_xpath(get_following_status.__name__, "follow_button_XP")
    except NoSuchElementException:
        try:
github Instagram-Tools / bot / instapy / commenters_util.py View on Github external
def extract_information(browser, username, daysold, max_pic):
    """Get all the information for the given username"""
    web_address_navigator(browser, "https://www.instagram.com/" + username)

    try:
        num_of_posts = get_number_of_posts(browser)
        num_of_posts = min(num_of_posts, max_pic)
        # we don't need to scroll more than is max number of posts we want
        # to extract

    except Exception:
        print("\nError: Couldn't get user profile. Moving on..")
        return []

    # PROFILE SCROLLING AND HARVESTING LINKS
    try:
        body_elem = browser.find_element_by_tag_name("body")

        links = []
github Instagram-Tools / bot / instapy / unfollow_util.py View on Github external
def follow_user(browser, track, login, user_name, button, blacklist, logger, logfolder):
    """ Follow a user either from the profile page or post page or dialog
    box """
    # list of available tracks to follow in: ["profile", "post" "dialog"]

    # check action availability
    if quota_supervisor("follows") == "jump":
        return False, "jumped"

    if track in ["profile", "post"]:
        if track == "profile":
            # check URL of the webpage, if it already is user's profile
            # page, then do not navigate to it again
            user_link = "https://www.instagram.com/{}/".format(user_name)
            web_address_navigator(browser, user_link)

        # find out CURRENT following status
        following_status, follow_button = get_following_status(
            browser, track, login, user_name, None, logger, logfolder
        )
        if following_status in ["Follow", "Follow Back"]:
            click_visibly(browser, follow_button)  # click to follow
            follow_state, msg = verify_action(
                browser, "follow", track, login, user_name, None, logger, logfolder
            )
            if follow_state is not True:
                return False, msg

        elif following_status in ["Following", "Requested"]:
            if following_status == "Following":
                logger.info("--> Already following '{}'!\n".format(user_name))
github Instagram-Tools / bot / instapy / comment_util.py View on Github external
def get_comments_on_post(browser,
                         owner,
                         poster,
                         amount,
                         post_link,
                         ignore_users,
                         randomize,
                         logger):
    """ Fetch comments data on posts """

    web_address_navigator(browser, post_link)

    orig_amount = amount
    if randomize is True:
        amount = amount * 3

    # check if commenting on the post is enabled
    commenting_state, msg = is_commenting_enabled(browser, logger)
    if commenting_state is not True:
        logger.info(msg)
        return None

    # check if there are any comments in the post
    comments_count, msg = get_comments_count(browser, logger)
    if not comments_count:
        logger.info(msg)
        return None