【发布时间】:2017-10-15 19:32:36
【问题描述】:
我想使用 webshot R 库从特定站点将一些 Web 元素导出到 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
【问题讨论】:
标签: javascript jquery html r phantomjs