Selenium使用小结

Chrome浏览器无头模式

1
2
3
4
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(chrome_options=chrome_options)

Chrome浏览器设置窗口大小

1
2
3
4
5
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
chrome_options = Options()
chrome_options.add_argument("window-size=1050,840")
browser = webdriver.Chrome(chrome_options=chrome_options)