#coding=utf-8 from selenium import webdriver import time chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') driver=webdriver.Chrome(chrome_options=chrome_options,executable_path=r"C:UserswecashAppDataLocalGoogleChromeApplicationchromedriver.exe") driver.get('https://www.baidu.com/?tn=93380420_hao_pg') driver.find_element_by_id('kw').send_keys('测试') time.sleep(3) driver.get_screenshot_as_file(r"C:UserswecashDesktopaidu.png")
官网:https://developers.google.cn/web/updates/2017/04/headless-chrome