【问题标题】:Rselenium - How to disable images in Firefox profileRselenium - 如何在 Firefox 配置文件中禁用图像
【发布时间】:2017-07-02 12:50:14
【问题描述】:

在 Rselenium 中使用 Firefox 时如何禁用图像下载?我想看看这样做是否会使抓取脚本更快。

我已阅读 Reselnium 软件包手册,包括有关 getFirefoxProfile 和 makeFirefoxProfile 的部分。

我找到了this link that shows how to handle chromedriver

我可以禁用我在 Windows 10 中手动打开的 Firefox 实例的图像,但 Rselenium 似乎没有使用相同的配置文件。

【问题讨论】:

    标签: r windows firefox rselenium


    【解决方案1】:

    之前您需要设置适当的首选项(在这种情况下 permissions.default.image) 但是现在 Firefox 重置此值存在问题,请参阅:

    https://github.com/seleniumhq/selenium/issues/2171

    给出了解决方法:

    https://github.com/gempesaw/Selenium-Remote-Driver/issues/248

    RSelenium 中实现这个:

    library(RSelenium)
    fprof <- makeFirefoxProfile(list(permissions.default.image = 2L,
                                     browser.migration.version = 9999L))
    rD <- rsDriver(browser = "firefox", extraCapabilities = fprof)
    remDr <- rD$client
    remDr$navigate("http://www.google.com/ncr")
    remDr$screenshot(display = TRUE)
    
    # clean up
    rm(rD)
    gc()
    

    【讨论】:

    猜你喜欢
    • 2013-05-26
    • 1970-01-01
    • 2020-12-28
    • 2018-02-08
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    • 2016-02-06
    • 2011-12-29
    相关资源
    最近更新 更多