r - rselenium | get the text of the webpage -
is there way plain text remotedriver in rselenium? somethink like: remdr$getplaintext()
equivalent remdr$getpagesource()
.
workarount:
i managed save phantomjs's plaintext file follows:
require(rselenium) pjs <- phantom() sys.sleep(5) # give binary moment remdr = remotedriver(browsername = 'phantomjs') remdr$open() remdr$phantomexecute('var page = this; var fs = require(\"fs\"); page.onloadfinished = function(status) { var txtfile = fs.open(\"url.txt\", \"w\"); txtfile.write(page.plaintext); txtfile.close(); };') remdr$navigate(some_url)
but have read file in afterwords...
my workaround done similar https://cran.r-project.org/web/packages/rselenium/vignettes/rselenium-headless.html#id3b
i not sure whether if solves problem.
library(rselenium) checkforserver() startserver() re<-remotedriver() re$open() re$navigate("link") txt<-re$findelement(using='css selector',"body")$getelementtext()
Comments
Post a Comment