urltools (version 1.1.0)

url_parse: split URLs into their component parts

Description

url_parse takes a vector of URLs and splits each one into its component parts, as recognised by RfC 3986.

Usage

url_parse(urls)

Arguments

urls
a vector of URLs

Value

  • a list of vectors, one for each URL, with each vector containing (in sequence) the URL's scheme, domain, port, path, query string and fragment identifier. See the http://tools.ietf.org/html/rfc3986{relevant IETF RfC} for definitions. If an element cannot be identified, it is replaced with an empty string.

Details

It's useful to be able to take a URL and split it out into its component parts - for the purpose of hostname extraction, for example, or analysing API calls. This functionality is not provided in base R, although it is provided in parse_url; that implementation is entirely in R, uses regular expressions, and is not vectorised. It's perfectly suitable for the intended purpose (decomposition in the context of automated HTTP requests from R), but not for large-scale analysis.

See Also

url_parameters for extracting values associated with particular keys in a URL's query string.

Examples

Run this code
url_parse("https://en.wikipedia.org/wiki/Article")

Run the code above in your browser using DataLab