【问题标题】:How to get rid of getting alert "This type of files may harm your computer. Do you want to keep or discard?" [duplicate]如何摆脱警报“这种类型的文件可能会损害您的计算机。您要保留还是丢弃?” [复制]
【发布时间】:2019-12-03 04:11:35
【问题描述】:

我正在尝试在 python 中使用 selenium 和 chrome webdriver 从网站下载文件,并且我收到了保留或丢弃的警报。我已经尝试了 stackoverflow 上提到的所有方法来更改 chrome 选项和首选项,但没有用。

提前致谢

【问题讨论】:

  • 如果您有文件的确切 URL,您可以使用来自 from urllib.requesturlretrieve("URL","File Name")
  • 我无法使用 url 路径,因为它是我网页的默认设置,只有页面内容被更改。 @TekNath

标签: python selenium google-chrome


【解决方案1】:

你试过了吗?

chromeOptions = webdriver.ChromeOptions()
  prefs = {'safebrowsing.enabled': 'false'}
  chromeOptions.add_experimental_option("prefs", prefs)
  driver = webdriver.Chrome(chrome_options=chromeOptions)

【讨论】:

  • 是的...我已经尝试过这些东西preferences = {"download.default_directory": download_dir, "download.prompt_for_download": False, "profile.default_content_settings.popups": 0, "download.extensions_to_open ": 'inf', "download.extensions_to_open": 'cfg', "safebrowsing.enabled": True, "profile.default_content_setting_values.automatic_downloads": 1} @Amruta
猜你喜欢
  • 2011-09-10
  • 2018-08-24
  • 1970-01-01
  • 2020-10-30
  • 2018-07-19
  • 1970-01-01
  • 2016-10-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多