#' Execute a custom rendering script and return a result.
#'
#' @md
#' @param splash_obj Object created by a call to [splash]
#' @param lua_sourc Browser automation script. See [Splash Script](http://splash.readthedocs.io/en/stable/scripting-tutorial.html#scripting-tutorial) Tutorial for more info.
#' @param timeout A timeout (in seconds) for the render (defaults to 30).
#' @param allowed_domains Comma-separated list of allowed domain names. If present, Splash won’t load anything neither from domains not in this list nor from subdomains of domains not in this list.
#' @param proxy Proxy profile name or proxy URL.
#' @param filters Comma-separated list of request filter names.
#' @param save_args A list of argument names to put in cache.
#' @param load_args Parameter values to load from cache
#' @return `raw` content from the `httr` call. Given the vast diversity of possible return values, it's up to the caller to handle the return value.
@ -12,8 +12,8 @@ It's also an alternative to `phantomjs` (which you can use in R within or withou
You can also get it running with two commands:
sudo docker pull scrapinghub/splash
sudo docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 scrapinghub/splash
sudo docker pull hrbrmstr/splashttpd
sudo docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 hrbrmstr/splashttpd
(Do whatever you Windows ppl do with Docker on your systems to make ^^ work.)
@ -43,6 +43,7 @@ The following functions are implemented:
- `render_har`: Return information about Splash interaction with a website in [HAR](http://www.softwareishard.com/blog/har-12-spec/) format.
- `render_jpeg`: Return a image (in JPEG format) of the javascript-rendered page.
- `render_png`: Return a image (in PNG format) of the javascript-rendered page.
- `execute_lua`: Execute a custom rendering script and return a result.
- `splash`: Configure parameters for connecting to a Splash server
- `install_splash`: Retrieve the Docker image for Splash
- `start_splash`: Start a Splash server Docker container
@ -56,7 +57,7 @@ Suggest more in a feature req!
- <strike>Implement `render.json`</strike>
- <strike>Implement "file rendering"</strike>
- Implement `execute` (you can script Splash!)
- <strike>Implement `execute` (you can script Splash!)</strike>
- <strike>Add integration with [`HARtools`](https://github.com/johndharrison/HARtools)</strike>
- <strike>_Possibly_ writing R function wrappers to install/start/stop Splash</strike> which would also support enabling javascript profiles, request filters and proxy profiles from with R directly, using [`harbor`](https://github.com/wch/harbor)
- Testing results with all combinations of parameters
@ -141,14 +142,28 @@ splash("splash", 8050L) %>%

### Rendering Widgets
### Executing custom Lua scripts
```{r}
splash_vm <- start_splash(add_tempdir=TRUE)
lua_ex <- '
function main(splash)
splash:go("http://rud.is/b")
splash:wait(0.5)
local title = splash:evaljs("document.title")
return {title=title}
end
'
res <- splash("localhost") %>% execute_lua(lua_ex)
@ -9,8 +9,8 @@ It's also an alternative to `phantomjs` (which you can use in R within or withou
You can also get it running with two commands:
sudo docker pull scrapinghub/splash
sudo docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 scrapinghub/splash
sudo docker pull hrbrmstr/splashttpd
sudo docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 hrbrmstr/splashttpd
(Do whatever you Windows ppl do with Docker on your systems to make ^^ work.)
@ -40,6 +40,7 @@ The following functions are implemented:
- `render_har`: Return information about Splash interaction with a website in [HAR](http://www.softwareishard.com/blog/har-12-spec/) format.
- `render_jpeg`: Return a image (in JPEG format) of the javascript-rendered page.
- `render_png`: Return a image (in PNG format) of the javascript-rendered page.
- `execute_lua`: Execute a custom rendering script and return a result.
- `splash`: Configure parameters for connecting to a Splash server
- `install_splash`: Retrieve the Docker image for Splash
- `start_splash`: Start a Splash server Docker container
@ -53,7 +54,7 @@ Suggest more in a feature req!
- <strike>Implement `render.json`</strike>
- <strike>Implement "file rendering"</strike>
- Implement `execute` (you can script Splash!)
- <strike>Implement `execute` (you can script Splash!)</strike>
- <strike>Add integration with [`HARtools`](https://github.com/johndharrison/HARtools)</strike>
- <strike>*Possibly* writing R function wrappers to install/start/stop Splash</strike> which would also support enabling javascript profiles, request filters and proxy profiles from with R directly, using [`harbor`](https://github.com/wch/harbor)
- Testing results with all combinations of parameters
@ -91,7 +92,7 @@ splash("splash", 8050L) %>%
splash_active()
```
## Status of splash instance on [http://splash:8050]: ok. Max RSS: 462295040
You can use [`HARtools::HARviewer`](https://github.com/johndharrison/HARtools/blob/master/R/HARviewer.R) — which this pkg import/exports — to get view the HAR in an interactive HTML widget.
@ -188,14 +189,33 @@ splash("splash", 8050L) %>%

### Executing custom Lua scripts
``` r
lua_ex <-'
function main(splash)
splash:go("http://rud.is/b")
splash:wait(0.5)
local title = splash:evaljs("document.title")
return {title=title}
end
'
res <-splash("localhost")%>% execute_lua(lua_ex)
rawToChar(res) %>%
jsonlite::fromJSON()
```
## $title
## [1] "rud.is | \"In God we trust. All others must bring data\""
\item{splash_obj}{Object created by a call to \link{splash}}
\item{timeout}{A timeout (in seconds) for the render (defaults to 30).}
\item{allowed_domains}{Comma-separated list of allowed domain names. If present, Splash won’t load anything neither from domains not in this list nor from subdomains of domains not in this list.}
\item{proxy}{Proxy profile name or proxy URL.}
\item{filters}{Comma-separated list of request filter names.}
\item{save_args}{A list of argument names to put in cache.}
\item{load_args}{Parameter values to load from cache}
\item{lua_sourc}{Browser automation script. See \href{http://splash.readthedocs.io/en/stable/scripting-tutorial.html#scripting-tutorial}{Splash Script} Tutorial for more info.}
}
\value{
\code{raw} content from the \code{httr} call. Given the vast diversity of possible return values, it's up to the caller to handle the return value.
}
\description{
Execute a custom rendering script and return a result.