chromedriver添加代理

Categories: Python

from selenium import webdriver

from selenium.webdriver.chrome.options import Options



chrome_options = Options()

chrome_options.add_argument("--headless")

chrome_options.add_argument("--no-sandbox")

chrome_options.add_argument("--proxy-server=socks5://127.0.0.1:1080")

driver = webdriver.Chrome(executable_path='/opt/chromedriver', chrome_options=chrome_options)

driver.get('http://pythonscraping.com')

See also