我试图通过Rselenium下载文件,但看起来不可能。即使有一个简单的例子我也不会下载:
require(RSelenium)
fprof <- makeFirefoxProfile(list(browser.download.dir = "C:/temp"
, browser.download.folderList = 2L
, browser.download.manager.showWhenStarting = FALSE
, browser.helperApps.neverAsk.saveToDisk = "application/zip"))
remDr <- remoteDriver(browserName = "firefox",remoteServerAddr = "192.168.99.100",port = 4445L,extraCapabilities = fprof)
remDr$open(silent = TRUE)
remDr$navigate("https://www.chicagofed.org/applications/bhc/bhc-home")
# click year 2012
webElem <- remDr$findElement("name", "SelectedYear")
webElems <- webElem$findChildElements("css selector", "option")
webElems[[which(sapply(webElems, function(x){x$getElementText()}) == "2012" )]]$clickElement()
# click required quarter
webElem <- remDr$findElement("name", "SelectedQuarter")
Sys.sleep(1)
webElems <- webElem$findChildElements("css selector", "option")
webElems[[which(sapply(webElems, function(x){x$getElementText()}) == "4th Quarter" )]]$clickElement()
# click button
webElem <- remDr$findElement("id", "downloadDataFile")
webElem$clickElement()
答案 0 :(得分:1)
如果您将Docker工具箱与Windows一起使用,则可能会遇到映射卷的问题,请参阅Docker : Sharing a volume on Windows with Docker toolbox
如果您在Mac或Windows上使用Docker Machine,您的Docker守护程序只能有限地访问您的OS X或Windows文件系统。 Docker Machine尝试自动共享您的/ Users(OS X)或C:\ Users(Windows)目录。
我在Windows 10框上启动了一个干净的docker工具箱安装,并运行了以下图像:
$ docker stop $(docker ps -aq)
$ docker rm $(docker ps -aq)
$ docker run -d -v //c/Users/john/test/://home/seluser/Downloads -p 4445:4444 -p 5901:5900 selenium/standalone-firefox-debug:2.53.1
注意:我们映射到Users / john空间中的目录。用户john正在运行docker toolbox
运行以下代码
require(RSelenium)
fprof <- makeFirefoxProfile(list(browser.download.dir = "home/seluser/Downloads"
, browser.download.folderList = 2L
, browser.download.manager.showWhenStarting = FALSE
, browser.helperApps.neverAsk.saveToDisk = "application/zip"))
remDr <- remoteDriver(browserName = "firefox",remoteServerAddr = "192.168.99.100",port = 4445L,extraCapabilities = fprof)
remDr$open(silent = TRUE)
remDr$navigate("https://www.chicagofed.org/applications/bhc/bhc-home")
# click year 2012
webElem <- remDr$findElement("name", "SelectedYear")
webElems <- webElem$findChildElements("css selector", "option")
webElems[[which(sapply(webElems, function(x){x$getElementText()}) == "2012" )]]$clickElement()
# click required quarter
webElem <- remDr$findElement("name", "SelectedQuarter")
Sys.sleep(1)
webElems <- webElem$findChildElements("css selector", "option")
webElems[[which(sapply(webElems, function(x){x$getElementText()}) == "4th Quarter" )]]$clickElement()
# click button
webElem <- remDr$findElement("id", "downloadDataFile")
webElem$clickElement()
并检查映射的下载文件夹
> list.files("C://Users/john/test")
[1] "bhcf1212.zip"
>
答案 1 :(得分:0)
最后我决定彻底安装docker for windows(17.03.0)stable。 我需要减少可用的CPU数量(到1)和可用的ram(到1GB)。 我也分享了我的c(顺便说一句,必须有一个密码会话,否则你不能共享该目录 之后我重新启动了我的电脑 在R方面,不要忘记删除: remoteServerAddr =&#34; 192.168.99.100&#34; 我收到了文件。