Rselenium - 如何在Firefox配置文件中禁用图像

时间:2017-07-02 12:50:15

标签: r windows firefox rselenium

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

我已阅读Reselnium包装手册,其中包括有关getFirefoxProfile& amp; makeFirefoxProfile。

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

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

1 个答案:

答案 0 :(得分: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()
相关问题