petermeissner
petermeissner

Reputation: 12861

Is there a way to evaluate JavaScript from within R?

Is there a way to evaluate JavaScript from within R?

What I mean is there is any way that I can e.g. get access to content that is dynamically created within a web page via JavaScript? I am not talking about some clever workaround like to access raw data that JavaScript is getting from elsewhere.

I suppose the answer is no as all questions posed in this direction where solved by some indirect clever way but I am not 100% sure. Also I would feel enlightened if somebody could tell me why this is impossible or not.

Upvotes: 0

Views: 122

Answers (1)

nograpes
nograpes

Reputation: 18323

Yeah, I thought that there wouldn't be, but I came across the SpiderMonkey package which seems to do exactly that. It will be a pain to compile it in Windows, though.


I don't think the package has been released on CRAN. You'll have to install it straight from Omegahat repo. There are more details at the Omegahat site.

Assuming that you have Rffi installed, which itself requires libffi, and the bitops package, you could just do this:

install.packages('SpiderMonkey', repos = "http://www.omegahat.org/R",type='source')

If you're on Windows, you'll have to have Rtools installed and properly configured. Also, compiling libffi will be difficult, but Duncan Temple Lang indicates that he has been successful at least once (look in README.win in the Rffi source).

Upvotes: 2

Related Questions