selenium+Chrome 无头模式 及加代理
1.selenium+Chrome 无头模式
示例代码:
# coding=utf-8
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.xxx.com")
print(driver.page_source)
driver.quit()
2.selenium+Chrome 添加 代理
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument("--proxy-server=http://119.117.24.185:8943")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.xxx.com")
print(driver.page_source)
driver.quit()