Rselenium - 如何在 Firefox 配置文件中禁用图像
Rselenium - How to disable images in Firefox profile
如何在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 时禁用图像下载?我想看看这样做是否能让抓取脚本更快。
我已阅读 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()