我正在使用webshot的开发版。我在下面有两段代码。一个没有问题,另一个没有用。
webshot不能用于更大的循环吗?
工作代码:
library(tidyverse)
library(rvest)
library(plyr)
devtools::install_github("wch/webshot")
testloop <- c("aapl", "fit", "amzn",
"ASPN", "CCM", "CGG",
"CGI", "CHK" ,
"CMU")
#, "CSLT", "DHT")
for (i in testloop) {
wurlShot <- paste("http://www.nasdaq.com/symbol/",i, "/stock-chart", sep = '')
savepngname <- paste('"', i, ".png")
webshot(wurlShot, file = paste('testfolder/',i, '.png', sep =''),
selector = ".marginT5px img")
}
但是当我删除注释并在循环中再添加两个运行时:
testloop <- c("aapl", "fit", "amzn",
"ASPN", "CCM", "CGG",
"CGI", "CHK" ,
"CMU", "CSLT", "DHT", "msft")
for (i in testloop) {
wurlShot <- paste("http://www.nasdaq.com/symbol/",i, "/stock-chart", sep = '')
savepngname <- paste('"', i, ".png")
webshot(wurlShot, file = paste('testfolder/',i, '.png', sep =''),
selector = ".marginT5px img")
}
我收到此错误:
Error in webshot(wurlShot, file = paste("testfolder/", i, ".png", sep = ""), :
webshot.js returned failure value: 1
In addition: Warning message:
running command '"C:\Users\John\AppData\Roaming/PhantomJS/phantomjs.exe"
"C:/Users/John/Documents/R/win-library/3.3/webshot/webshot.js" "
[{\"url\":\"http://www.nasdaq.com/symbol/CGI/stock-chart\",\"file\":\"testfolder/CGI.png\",\"vwidth\":992,\"vheight\":744,\"selector\":\".marginT5px img\",\"delay\":0.2,\"zoom\":1}]"' had status 1
唯一不同的是在第二个循环中完成了更多循环。它有失败的原因吗?