selenium 要禁用一些功能怎麼改?
selenium 要 禁用css 禁用flash 禁用js 禁用圖片
代碼需要加再哪裡???怎麼改??
禁用css
firefox_profile.set_preference('permissions.default.stylesheet', 2)
禁用flash
firefox_profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', 'false')
禁用js
firefox_profile.set_preference('javascript.enabled', 'false')
禁用圖片
firefox_profile.option.set_preference('permissions.default.image', 2)
程序代码:
from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') driver = webdriver.Chrome(ChromeDriverManager().install(),chrome_options=chrome_options) url = 'https://' driver.get(url)