mirror of https://git.sr.ht/~hrbrmstr/splashr
10 changed files with 148 additions and 44 deletions
@ -1,2 +1,8 @@ |
|||
0.2.0 |
|||
|
|||
* added `execute`() |
|||
* modified `splash_active`() |
|||
|
|||
0.1.0 |
|||
|
|||
* Initial release |
|||
|
@ -0,0 +1,33 @@ |
|||
#' 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. |
|||
#' @export |
|||
execute_lua <- function(splash_obj, lua_source, timeout=30, allowed_domains, |
|||
proxy, filters, save_args, load_args) { |
|||
|
|||
params <- list(lua_source=lua_source, timeout=timeout) |
|||
|
|||
if (!missing(allowed_domains)) params$allowed_domains <- allowed_domains |
|||
if (!missing(proxy)) params$proxy <- proxy |
|||
if (!missing(filters)) params$filters <- filters |
|||
if (!missing(save_args)) params$save_args <- save_args |
|||
if (!missing(load_args)) params$load_args <- load_args |
|||
|
|||
res <- httr::GET(splash_url(splash_obj), path="execute", encode="json", query=params) |
|||
|
|||
httr::stop_for_status(res) |
|||
|
|||
out <- httr::content(res, as="raw") |
|||
|
|||
out |
|||
|
|||
} |
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 123 KiB |
Before Width: | Height: | Size: 466 KiB After Width: | Height: | Size: 437 KiB |
@ -0,0 +1,32 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/execute.r |
|||
\name{execute_lua} |
|||
\alias{execute_lua} |
|||
\title{Execute a custom rendering script and return a result.} |
|||
\usage{ |
|||
execute_lua(splash_obj, lua_source, timeout = 30, allowed_domains, proxy, |
|||
filters, save_args, load_args) |
|||
} |
|||
\arguments{ |
|||
\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. |
|||
} |
Loading…
Reference in new issue