html_links: Links in a document

View source: R/links.R

html_linksR Documentation

Description

Finds the ⁠<a>⁠ and ⁠<area>⁠ elements with an href below the given nodes (and the nodes themselves), in document order, without duplicates. Duplicate destinations are kept, and so are fragment, ⁠mailto:⁠ and ⁠tel:⁠ links.

Usage

html_links(x, absolute = FALSE)

Arguments

x

A zuhtml_document or zuhtml_nodeset.

absolute

If TRUE, url is resolved with html_url(); otherwise it is href unchanged.

Value

A data frame with one row per link and character columns text (the link's cleaned text, see html_text_clean()), href (the attribute as written, decoded) and url.

See Also

Other extraction: html_forms(), html_list(), html_table(), html_table_cells(), html_url()

Examples

doc <- html_parse(
  "<nav><a href='/'>Home</a> <a href='about.html'>About</a></nav>",
  base_url = "https://example.org/site/"
)
html_links(doc)
html_links(doc, absolute = TRUE)

zuhtml documentation built on Oct. 6, 2026, 5:06 p.m.