我使用 Selenium Marrionette 和 GeckoDriver 来提取 Web 数据。我使用以下设置我的 Firefox 配置文件首选项:
fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList", 1)
fp.set_preference("browser.helperApps.alwaysAsk.force", False)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.dir", "H:\Downloads")
fp.set_preference("browser.download.downloadDir","H:\Downloads")
fp.set_preference("browser.download.defaultFolder","H:\Downloads")
binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\Firefox.exe')
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
driver = webdriver.Firefox(capabilities=firefox_capabilities, firefox_binary=binary, firefox_profile = fp)
根据我在阅读Unable to set firefox profile preferences和FirefoxProfile 传递给 FirefoxDriver后的理解,现在使用时似乎没有做任何事情firefox_profile
。所以我需要实施新的更新firefox_capabilities
,但我不确定如何准确地做到这一点。有任何想法吗?