在 Rselenium 中使用 Firefox 时如何禁用图像下载?我想看看这样做是否会使抓取脚本更快。
我已阅读 Reselnium 软件包手册,包括有关 getFirefoxProfile 和 makeFirefoxProfile 的部分。
我找到了this link that shows how to handle chromedriver 。
我可以禁用在 Windows 10 中手动打开的 Firefox 实例的图像,但 Rselenium 似乎不使用相同的配置文件。
最佳答案
以前您需要设置适当的首选项(在本例中
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()
关于Rselenium - 如何禁用 Firefox 配置文件中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44871005/