host_extract: Extract hosts

Description Usage Arguments Value Examples

View source: R/suffix.R

Description

host_extract extracts the host from a vector of domain names. A host isn't the same as a domain - it could be the subdomain, if there are one or more subdomains. The host of en.wikipedia.org is en, while the host of wikipedia.org is wikipedia.

Usage

1
host_extract(domains)

Arguments

domains

a vector of domains, retrieved through url_parse or domain.

Value

a data.frame of two columns: domain, with the original domain names, and host, the identified host from the domain.

Examples

1
2
3
4
5
6
7
# With subdomains
has_subdomain <- domain("https://en.wikipedia.org/wiki/Main_Page")
host_extract(has_subdomain)

# Without
no_subdomain <- domain("https://ironholds.org/projects/r_shiny/")
host_extract(no_subdomain)

Example output

            domain host
1 en.wikipedia.org   en
         domain      host
1 ironholds.org ironholds

urltools documentation built on May 1, 2019, 6:49 p.m.