from selenium import webdriver import time fireFoxOptions = webdriver.FirefoxOptions() fireFoxOptions.set_headless() driver = webdriver.Firefox(firefox_options=fireFoxOptions) 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")