selenium
selenium headless
- 系列文章目录
- 前言
- 一、selenium headless
- 参考
前言
selenium headless 不打开浏览器界面
一、selenium headless
- macos
from optparse import Option
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')
chrome_options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
browser = webdriver.Chrome(options=chrome_options)
url = 'https://www.baidu.com/'
browser.get(url)
browser.save_screenshot('baidu.png')
参考
- 尚硅谷Python爬虫教程小白零基础速通(含python基础+爬虫案例)
- Web Scraping with Selenium and Headless Chrome on macOS



