为chrome设置代理IP。
from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument('--headless') base_url = "http://www.baidu.com/" driver = webdriver.Chrome(options = chrome_options) driver.get(base_url + "/") driver.find_element_by_id("kw").send_keys("Python程序设计") driver.find_element_by_id("su").click() driver.save_screenshot('screen.png') driver.close()