Webshot with R:webshot.js返回失败值1

时间:2017-05-16 15:54:14

标签: javascript jquery html r phantomjs

我想从包含webshot R库的特定网站导出png文件中的一些网络元素。

首先,安装和加载库:

install.packages("webshot",dependencies = TRUE)
library(webshot)
webshot::install_phantomjs()

我正在使用 www.google.es 网址测试webshot()。效果很好:

webshot("https://www.google.es/","google.png", selector="#hplogo")

enter image description here

但是如果我想将搜索引擎元素导出到PNG图像:

enter image description here 我写了以下代码:

webshot("https://www.google.es/","google.png", selector=".tsf-p")

有什么问题?

> webshot("https://www.google.es/","google.png", selector=".tsf-p")
PHANTOM ERROR: CasperError: No element matching selector found: .tsf-p
TRACE:
 -> phantomjs://platform/casper.js: 1066 (in function getElementBounds)
 -> phantomjs://code/webshot.js: 137
 -> undefined: 0 (in function map)
 -> phantomjs://code/webshot.js: 136 (in function findClipRect)
 -> phantomjs://code/webshot.js: 85
 -> phantomjs://platform/casper.js: 2188 (in function _check)
Error in webshot("https://www.google.es/", "google.png", selector = ".tsf-p") : 
  webshot.js returned failure value: 1
In addition: Warning message:
running command '"C:\Users\Mario Martínez\AppData\Roaming/PhantomJS/phantomjs.exe" "C:/Users/Mario Martínez/Documents/R/win-library/3.3/webshot/webshot.js" "[{\"url\":\"https://www.google.es/\",\"file\":\"google.png\",\"vwidth\":992,\"vheight\":744,\"selector\":\".tsf-p\",\"delay\":0.2,\"zoom\":1}]"' had status 1 

0 个答案:

没有答案