Tools to Work with the 'Splash' JavaScript Rendering Service in R
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4KB

  1. # Return the HTML or image (png) of the javascript-rendered page in a local file
  2. #
  3. # The suggested use-case for this is rendering a widget
  4. #
  5. # TODO Test if container is running
  6. # TODO Enable passing in of an htmlwidget and use saveWidget
  7. #
  8. # @md
  9. # @param splash_obj Object created by a call to [splash()]
  10. # @param file_path Absolute path to a filename on the local host. **This only works with a locally running Splash instance started with [start_splash]().**
  11. # @param wait seconds to wait
  12. # @param output either `html` or `png` to get the page content or an image capture
  13. # @param viewport View width and height (in pixels) of the browser viewport to render the web page. Format is "`<width>x<height>`". e.g. 800x600. Default value is 1024x768.
  14. # @param ... other params to [render_html()] or [render_png()]
  15. # @family splash_renderers
  16. # @return An XML document or `magick` object
  17. # @export
  18. # render_file <- function(splash_obj = splash_local, file_path, output=c("html", "png"), wait=0, viewport="1024x768", ...) {
  19. #
  20. # wait <- check_wait(wait)
  21. #
  22. # output <- match.arg(output, c("html", "png"))
  23. #
  24. # file.copy(file_path, .pkgenv$temp_dir)
  25. #
  26. # fil <- basename(file_path)
  27. #
  28. # URL <- sprintf("http://localhost:9999/%s", fil)
  29. #
  30. # if (output == "html") {
  31. # render_html(splash_obj, URL, wait=wait, viewport=viewport, ...)
  32. # } else {
  33. # render_png(splash_obj, URL, wait=wait, viewport=viewport, ...)
  34. # }
  35. #
  36. # }