Skip to content

Instantly share code, notes, and snippets.

@romainfrancois
Created November 9, 2018 07:38
Show Gist options
  • Save romainfrancois/e9745c188b06b67fd592271942bd5294 to your computer and use it in GitHub Desktop.
Save romainfrancois/e9745c188b06b67fd592271942bd5294 to your computer and use it in GitHub Desktop.
library(rvest)
#> Loading required package: xml2
library(glue)

synonyms <- function(word) {
  glue("https://www.thesaurus.com/browse/{word}") %>% 
    read_html() %>% 
    html_nodes(".synonyms-container span a[data-linkid]") %>% 
    html_text()
}
sample(synonyms("mutate"), 1L)
#> [1] "commute"
sample(synonyms("summarize"), 1L)
#> [1] "downsize"
sample(synonyms("filter"), 1L)
#> [1] "rarefy"

Created on 2018-11-09 by the reprex package (v0.2.1.9000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment