If there is a page in the active browser context, return the contents of the page.

wc_render(wc_obj, what = c("parsed", "html", "text"))

Arguments

wc_obj

a webclient object

what

what to return (see Details); NOTE that if there is no active page this function returns NULL.

Value

if what is parsed, an xml2 html_document; if html, the character HTML representation of the page; if text the rendered text of the document as viewed by a human.

Details

The page contents can be returned as one of:

  • Parsed HTML (i.e. an xml2 html_document)

  • A string representation of the HTML document. NOTE: The charset used is the current page encoding.

  • A textual representation of this page that represents what would be visible to the user if this page was shown in a web browser. This is useful for, say, text mining.

Note

This is an information retrieval function that does not return the wc_obj so must be the last function call in a webclient pipe.

Examples

w <- web_client()
wc_go(w, url = "https://hrbrmstr.github.io/htmlunitjars/index.html")
wc_render(w, "parsed")
wc_render(w, "html")
wc_render(w, "text")