rvest (version 0.3.6)

html_text: Extract attributes, text and tag name from html.

Description

Extract attributes, text and tag name from html.

Usage

html_text(x, trim = FALSE)

html_name(x)

html_children(x)

html_attrs(x)

html_attr(x, name, default = NA_character_)

Arguments

x

A document, node, or node set.

trim

If TRUE will trim leading and trailing spaces.

name

Name of attribute to retrieve.

default

A string used as a default value when the attribute does not exist in every node.

Value

html_attr, html_tag and html_text, a character vector; html_attrs, a list.

Examples

Run this code
# NOT RUN {
movie <- read_html("https://en.wikipedia.org/wiki/The_Lego_Movie")
cast <- html_nodes(movie, "tr:nth-child(8) .plainlist a")
html_text(cast)
html_name(cast)
html_attrs(cast)
html_attr(cast, "href")
# }

Run the code above in your browser using DataLab