Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将自动取消跟踪模块添加到休闲代码中?_Python_Python 3.x_Pycharm_Instagram - Fatal编程技术网

Python 如何将自动取消跟踪模块添加到休闲代码中?

Python 如何将自动取消跟踪模块添加到休闲代码中?,python,python-3.x,pycharm,instagram,Python,Python 3.x,Pycharm,Instagram,这是一段python代码,列出了我只关注的用户。我想通过添加一个自动展开模块来使用相同的列表: 。 . 这是我写的代码,并努力解开下面我想要的列表 def do_unfolow(列表): 对于列表中的x: 打印(x) browser.get('https://www.instagram.com/“+x) def get_unfollowers(browser): """ Opens the profile, obtains the follower

这是一段python代码,列出了我只关注的用户。我想通过添加一个自动展开模块来使用相同的列表:

。 .


这是我写的代码,并努力解开下面我想要的列表

def do_unfolow(列表): 对于列表中的x: 打印(x) browser.get('https://www.instagram.com/“+x)

def get_unfollowers(browser):
    """
    Opens the profile, obtains the follower and following list
    Returns the names of the users who are in the following list, but not in the follower list
    """
    to_profile = browser.find_element_by_xpath("//a[contains(@href, '/{}')]".format(username))
    to_profile.click()
    sleep(3)
    to_following = browser.find_element_by_xpath("//a[contains(@href, '/following')]")
    to_following.click()
    following_list = get_name(browser)
    to_followers = browser.find_element_by_xpath("//a[contains(@href, '/followers')]")
    to_followers.click()
    followers_list = get_name(browser)
    not_following_back = [user for user in following_list if user not in followers_list]

    print(not_following_back)  # prints a list with every name separated by a comma
 


def get_name(browser):

    sleep(2)
    scroll_box = browser.find_element_by_class_name('isgrP')
    p_height, height = 0, 1
    while p_height != height:
        p_height = height
        sleep(2)
        height = browser.execute_script(
            "arguments[0].scrollTo(0, arguments[0].scrollHeight); return arguments[0].scrollHeight;", scroll_box)
    total_list = scroll_box.find_elements_by_tag_name('li')
    names = [name.text for name in total_list if name.text != '']
    close_dub = browser.find_element_by_xpath("/html/body/div[4]/div/div/div[1]/div/div[2]/button")
    close_dub.click()
    return names



get_unfollowers(browser)
    # tempy2 = browser.find_element_by_css_selector(".vBF20._1OSdk")
     #if not tempy2:
     tempy2 = browser.find_element_by_css_selector(".glyphsSpriteFriend_Follow")
     #tempy2 = browser.find_element_by_css_selector("Igw0E.rBNOH.YBx95._4EzTm")
     tempy2.click()
     tempy2 = browser.find_element_by_xpath("//button[contains(text(), 'Unfollow')]")
     tempy2.click()
     sleep(10)