ragnar_find_links: Find links on a page

View source: R/read-html.R

ragnar_find_linksR Documentation

Description

Find links on a page

Usage

ragnar_find_links(
  x,
  depth = 0L,
  children_only = FALSE,
  progress = TRUE,
  ...,
  url_filter = identity,
  validate = FALSE
)

Arguments

x

URL, HTML file path, or XML document. For Markdown, convert to HTML using commonmark::markdown_html() first.

depth

Integer specifying how many levels deep to crawl for links. When depth > 0, the function will follow child links (links with x as a prefix) and collect links from those pages as well.

children_only

Logical or string. If TRUE, returns only child links (those having x as a prefix). If FALSE, returns all links found on the page. Note that regardless of this setting, only child links are followed when depth > 0.

progress

Logical, draw a progress bar if depth > 0.

...

Currently unused. Must be empty.

url_filter

A function that takes a character vector of URL's and may subset them to return a smaller list. This can be useful for filtering out URL's by rules different than children_only which only checks the prefix.

validate

Default is FALSE. If TRUE sends a HEAD request for each link and removes those that are not accessible. Requests are sent in parallel using httr2::req_perform_parallel().

Value

A character vector of links on the page.

Examples

## Not run: 
ragnar_find_links("https://r4ds.hadley.nz/base-R.html")
ragnar_find_links("https://ellmer.tidyverse.org/")
ragnar_find_links(
  paste0("https://github.com/Snowflake-Labs/sfquickstarts/",
         "tree/master/site/sfguides/src/build_a_custom_model_for_anomaly_detection"),
  children_only = "https://github.com/Snowflake-Labs/sfquickstarts",
  depth = 1
)

## End(Not run)

ragnar documentation built on Sept. 11, 2026, 1:06 a.m.