我正在Mac和Windows中尝试在python脚本下运行。但是在Windows中,它可以正常工作;在Mac中,在脚本下运行时,出现以下错误。
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import datetime
mobile_emulation = {
"deviceMetrics": { "width": 411, "height": 731, "pixelRatio": 3.0 },
"userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"
};
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
chrome_options.add_argument("--no-sandbox");
chrome_options.add_argument("--disable-web-security");
chrome_options.add_argument("--ignore-urlfetcher-cert-requests");
chrome_options.add_argument("--disable-renderer-backgrounding");
chrome_options.add_argument("--disable-infobars");
chrome_options.add_argument("--start-maximized");
chrome_options.add_argument("--disable-dev-shm-usage");
chrome_options.add_experimental_option("useAutomationExtension", False);
chrome_options.add_argument("--log-level=3");
chrome_options.add_argument("--silent");
chrome_options.add_argument("--disable-gpu");
chrome_options.add_argument("window-size=1920,1080");
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=r'D://chromedriver')
driver.get("https://getbootstrap.com")