我想从包含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")
但是如果我想将搜索引擎元素导出到PNG图像:
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