import time
from selenium import webdriver
from selenium.common.exceptions import StaleElementReferenceException


def isUserLink(link):
    address = link.get_attribute('href')

    parent = link.find_element_by_xpath('..')
    return "/accounts/" not in address and \
           "/p/" not in address and \
           "/legal/" not in address and \
           'LI' in parent.get_property("tagName").upper() and \
           '/blog.instagram.com/' not in address and \
           '/about/' not in address and \
           '/explore/' not in address and \
           '/developer/' not in address and \
           'instagram-press.com' not in address and \
           'help.instagram.com' not in address


driver = webdriver.Chrome('./chromedriver')

username = "<Enter Username here>"
userLink = "https://www.instagram.com/" + username + "/"


def scrapeUser(userLink):
    driver.get(userLink)
    links = driver.find_elements_by_tag_name('a')
    users = []

    safetyCounter = 0
    for link in links:

        try:
            linkAdress = link.get_attribute("href")
        except StaleElementReferenceException:
            links = driver.find_elements_by_tag_name('a')[:safetyCounter]
            continue

        if "taken-by" in linkAdress:
            # print linkAdress
            link.click()

            time.sleep(3)
            potentialUsers = driver.find_elements_by_tag_name('a')
            if potentialUsers is not None:
                for potentialUser in potentialUsers:

                    if potentialUser.get_attribute('href') is not None and potentialUser.get_attribute(
                            'title') in potentialUser.get_attribute('href'):
                        parent = potentialUser.find_element_by_xpath('..')

                        if isUserLink(potentialUser):
                            users.append(potentialUser.get_attribute('href'))

                potentialCloseButtons = driver.find_elements_by_tag_name('button')

                for potentialCloseButton in potentialCloseButtons:
                    if 'CLOSE' in potentialCloseButton.text.upper():
                        potentialCloseButton.click()
        safetyCounter += 1
    return set(users)


def scrapeMultipleLevels(userLink, levels=1, previousList=set(), finalList=[]):
    if levels == 0:
        return finalList
    users = scrapeUser(userLink)
    finalList.extend(users)
    # Prevent endless loop
    users.discard(userLink)
    for oldUser in previousList:
        users.discard(oldUser)
    for link in users:
        # print link
        finalList.extend(scrapeMultipleLevels(link, levels - 1, users))

    return finalList


allUsers = list(set(scrapeMultipleLevels(userLink)))
# Uncomment for complete list
print allUsers
driver.close()

import json
import time
from selenium import webdriver
from selenium.common.exceptions import StaleElementReferenceException

import argparse

from BrowserScraper import BrowserScraper


def main():
    parser = argparse.ArgumentParser(prog="InstagramScraper", description='This is the instagram scraper tool. Enjoy.')
    parser.add_argument('--username', dest='username', help='instagram username of the user to be scraped.')
    parser.add_argument('--level', dest='level', help='friends level to scrape', default=1)
    parser.add_argument('--destination', dest='destination', help='filename where the scraped users are to be stored.',
                        default='scraped.json')
    arguments = parser.parse_args()

    scraper = BrowserScraper(arguments.username, arguments.level)
    allUsers = scraper.scrape()
    destination = arguments.destination
    if not destination.lower().endswith(".json"):
        destination += ".json"
    with open(destination, mode='w') as destinationFile:
        json.dump(allUsers, destinationFile)

    # print allUsers
    # print scraper.images
    scraper.closeDriver()


if __name__ == '__main__':
    main()

Add argument parser to instagram-scraper and use BrowserScraper for everything.