% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/html_getLinks.R
\name{html_getLinks}
\alias{html_getLinks}
\alias{html_getLinkNames}
\alias{html_getLinkUrls}
\title{Extract links from an HTML page}
\usage{
html_getLinks(url = NULL, relative = TRUE)

html_getLinkNames(url = NULL)

html_getLinkUrls(url = NULL, relative = TRUE)
}
\arguments{
\item{url}{URL or local file path of an HTML page.}

\item{relative}{Logical specifying whether to return relative URLs. If
\code{FALSE}, relative URLs are converted to absolute URLs using \code{url} as the
base.}
}
\value{
A tibble with \code{linkName} and \code{linkUrl} columns.

\code{html_getLinkNames()} returns a character vector of link names.

\code{html_getLinkUrls()} returns a character vector of link URLs.
}
\description{
Parse an HTML page and return all \verb{<a href="...">...</a>} links as a data
frame.
}
\details{
The returned data frame contains the human-readable link text in \code{linkName}
and the \code{href} value in \code{linkUrl}. This is useful for extracting links from
index pages, including web-accessible directories that list downloadable
files.

Wrapper functions \code{\link[=html_getLinkNames]{html_getLinkNames()}} and \code{\link[=html_getLinkUrls]{html_getLinkUrls()}} return the
corresponding columns as character vectors.
}
\examples{
\dontrun{

# If you want to download lots of USCensus shapefiles
url <- "https://www2.census.gov/geo/tiger/GENZ2019/shp/"

browseURL(url)

dataLinks <- html_getLinks(url)

dataLinks <-
  dataLinks \%>\%
  dplyr::filter(stringr::str_detect(linkName, "us_county"))

head(dataLinks, 10)

html_getLinkNames(url)
html_getLinkUrls(url, relative = FALSE)
}

}
