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)