selenium设置不加载css、javascript和图片

Chrome 的限制图片、javascript和css

from selenium import webdriver
from selenium.webdriver.chrome.options import Options


options = webdriver.ChromeOptions()
prefs = {
        'profile.default_content_setting_values': {
            'images': 2,
            'permissions.default.stylesheet':2,
            'javascript': 2
        }
    }
options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options)

你可能感兴趣的:(python,爬虫)