1from selenium import webdriver
2
3opt = webdriver.ChromeOptions()
4opt.add_argument("--disable-infobars")
5opt.add_argument("start-maximized")
6opt.add_argument("--disable-extensions")
7opt.add_argument("--start-maximized")
8opt.add_argument("no-sandbox")
9opt.add_argument("--disable-gpu")
10opt.add_argument("--disable-dev-shm-usage")
11opt.add_argument("--incognito")
12opt.add_argument("--headless")
13opt.add_argument("--disable-xss-auditor")
14opt.add_argument("--disable-web-security")
15opt.add_argument("--allow-running-insecure-content")
16opt.add_argument("--disable-setuid-sandbox")
17opt.add_argument("--disable-webgl")
18opt.add_argument("--disable-popup-blocking")
19# Pass the argument 1 to allow and 2 to block
20opt.add_experimental_option("prefs", {
21 "profile.default_content_setting_values.media_stream_mic": 2,
22 "profile.default_content_setting_values.media_stream_camera": 2,
23 "profile.default_content_setting_values.geolocation": 2,
24 "profile.default_content_setting_values.notifications": 2
25})
26driver = webdriver.Chrome(chromepath, chrome_options=opt)
27driver.get(url)
28
29# https://selenium-python.readthedocs.io/api.html