Package 'longurl'

Title: Expand Short 'URLs'
Description: Tools are provided to expand vectors of short URLs into long 'URLs'. No 'API' services are used, which may mean that this operates more slowly than 'API' services do (since they usually cache results of expansions that every user of the service requests). You can setup your own caching layer with the 'memoise' package if you wish to have a speedup during single sessions or add larger dependencies, such as 'Redis', to gain a longer-term performance boost at the expense of added complexity.
Authors: Bob Rudis [aut, cre] , John Coene [ctb] (Issue #4)
Maintainer: Bob Rudis <[email protected]>
License: MIT + file LICENSE
Version: 0.3.3
Built: 2024-12-17 05:42:33 UTC
Source: https://github.com/hrbrmstr/longurl

Help Index


Expand a vector of (short) URLs using

Description

Pass in a vector of URLs (ostensibly "short" URLs) and receive a data frame of the original URLs and expanded URLs

Usage

expand_urls(
  urls_to_expand,
  warn = TRUE,
  agent = "longurl-r-package",
  seconds = 5,
  .progress = FALSE
)

Arguments

urls_to_expand

character vector of URLs

warn

show any warnings (API or otherwise) as messages

agent

user agent to use (some sites switchup content based on user agents). Defaults to "'longurl-r-package'".

seconds

number of seconds to wait for a response until giving up. Cannot be <1ms.

.progress

kept for legacy functionality but ignored

Value

a tibble/data frame with the orignial URLs in 'orig_url', expanded URLs in 'expanded_url' and the HTTP 'status_code' of the expanded URL. Completely invalid URLs result in a 'NA' value for 'expanded_url' & 'status_code'.

Examples

test_urls <- c("http://t.co/D4C7aWYIiA",
               "1.usa.gov/1J6GNoW",
               "ift.tt/1L2Llfr")
big_urls <- expand_urls(test_urls)
head(big_urls)

Tools expand vectors of short URLs into long URLs

Description

Tools are provided to expand vectors of short URLs into long 'URLs'. No 'API' services are used, which may mean that this operates more slowly than 'API' services do (since they usually cache results of expansions that every user of the service requests). You can setup your own caching layer with the 'memoise' package if you wish to have a speedup during single sessions or add larger dependencies, such as 'Redis', to gain a longer-term performance boost at the expense of added complexity.

Author(s)

Bob Rudis ([email protected])