Skip to contents

xml2::read_html() can be used on a selenider session to read the HTML of the entire page, or on a selenider element to get the HTML of that element.

Usage

read_html.selenider_session(
  x,
  encoding = "",
  ...,
  options = c("RECOVER", "NOERROR", "NOBLANKS")
)

read_html.selenider_element(
  x,
  encoding = "",
  timeout = NULL,
  outer = TRUE,
  ...,
  options = c("RECOVER", "NOERROR", "NOBLANKS")
)

Arguments

x

A selenider_session/selenider_element object.

encoding, ..., options

Passed into xml2::read_html().

timeout

How long to wait for x to exist in the DOM before throwing an error.

outer

Whether to read the inner (all children of the current element) or outer (including the element itself) HTML of x.

Value

read_html() returns an XML document. Note that HTML will always be wrapped in a <html> and <body> tag, if it isn't already.

Examples

library(rvest)

html <- "
<div>
<p>Example text</p>
</div>
"

session <- minimal_selenider_session(html)

read_html(session)
read_html(s("div"))