''' option=webdriver.ChromeOptions() option.add_argument('headless') # 设置option driver = webdriver.Chrome(chrome_options=option) # 调用带参数的谷歌浏览器 ''' from selenium import webdriver option = webdriver.ChromeOptions() option.add_argument('headless') # 设置option driver = webdriver.Chrome(chrome_options=option) # 调用带参数的谷歌浏览器 driver.get("http://www.baidu.com") elem = driver.find_element_by_css_selector("span input[type='submit']") if elem : print("打开百度页面成功") else: print('打开百度页面失败') driver.quit()