简单小练习_知乎自动互粉

from selenium import webdriver

def start_chrome():
    driver = webdriver.Chrome(executable_path = './chromedriver')
    driver.start_client()
    return driver


def find_strangers():
    btn_sel = 'div.ContentItem-extra > button.Button--blue'
    elems = driver.find_elements_by_css_selector(btn_sel)
    return elems


while True:
    url = 'https://www.zhihu.com/'
    follower_url = 'https://www.zhihu.com/people/zhangfulong/followers'
    driver = start_chrome()
    driver.get(url)
    if not driver.get_cookies():
        push()
        time.sleep(20)
    driver.get(follower_url)
    time.sleep(6)
    strangers = find_strangers()
    for strange in strangers:
        strange.click()
        time.sleep(3)
        print('done!')

    time.sleep(3000)

 

posted @ 2018-06-29 13:30  Erick-LONG  阅读(165)  评论(0编辑  收藏  举报