Tools to Work with the 'Splash' JavaScript Rendering Service in R
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6KB

  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/execute.r
  3. \name{execute_lua}
  4. \alias{execute_lua}
  5. \title{Execute a custom rendering script and return a result.}
  6. \usage{
  7. execute_lua(splash_obj, lua_source, timeout = 30, allowed_domains, proxy,
  8. filters, save_args, load_args)
  9. }
  10. \arguments{
  11. \item{splash_obj}{Object created by a call to \link{splash}}
  12. \item{timeout}{A timeout (in seconds) for the render (defaults to 30).}
  13. \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.}
  14. \item{proxy}{Proxy profile name or proxy URL.}
  15. \item{filters}{Comma-separated list of request filter names.}
  16. \item{save_args}{A list of argument names to put in cache.}
  17. \item{load_args}{Parameter values to load from cache}
  18. \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.}
  19. }
  20. \value{
  21. \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.
  22. }
  23. \description{
  24. Execute a custom rendering script and return a result.
  25. }
  26. \examples{
  27. \dontrun{
  28. splash_local \%>\%
  29. execute_lua('
  30. function main(splash)
  31. splash:go("https://projects.fivethirtyeight.com/congress-trump-score/")
  32. splash:wait(0.5)
  33. return splash:evaljs("memberScores")
  34. end
  35. ') -> res
  36. rawToChar(res) \%>\%
  37. jsonlite::fromJSON(flatten=TRUE) \%>\%
  38. purrr::map(tibble::as_tibble) -> member_scores
  39. member_scores
  40. }
  41. }