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.

execute_lua.Rd 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 \code{\link[=splash]{splash()}}}
  12. \item{lua_source}{Browser automation script. See \href{http://splash.readthedocs.io/en/stable/scripting-tutorial.html#scripting-tutorial}{Splash Script} Tutorial for more info.}
  13. \item{timeout}{A timeout (in seconds) for the render (defaults to 30). Without
  14. reconfiguring the startup parameters of the Splash server (not this package)
  15. the maximum allowed value for the timeout is 60 seconds.}
  16. \item{allowed_domains}{Comma-separated list of allowed domain names. If present, Splash
  17. won’t load anything neither from domains not in this list nor from subdomains of
  18. domains not in this list.}
  19. \item{proxy}{Proxy profile name or proxy URL.}
  20. \item{filters}{Comma-separated list of request filter names.}
  21. \item{save_args}{A list of argument names to put in cache.}
  22. \item{load_args}{Parameter values to load from cache}
  23. }
  24. \value{
  25. \code{raw} content from the \code{httr} call. Given the vast diversity of possible return
  26. values, it's up to the caller to handle the return value.
  27. }
  28. \description{
  29. Execute a custom rendering script and return a result.
  30. }
  31. \examples{
  32. \dontrun{
  33. splash_local \%>\%
  34. execute_lua('
  35. function main(splash)
  36. splash:go("https://projects.fivethirtyeight.com/congress-trump-score/")
  37. splash:wait(0.5)
  38. return splash:evaljs("memberScores")
  39. end
  40. ') -> res
  41. rawToChar(res) \%>\%
  42. jsonlite::fromJSON(flatten=TRUE) \%>\%
  43. purrr::map(tibble::as_tibble) -> member_scores
  44. member_scores
  45. }
  46. }
  47. \seealso{
  48. Other splash_renderers: \code{\link{render_har}},
  49. \code{\link{render_html}}, \code{\link{render_jpeg}},
  50. \code{\link{render_json}}, \code{\link{render_png}}
  51. }
  52. \concept{splash_renderers}