Skip to content

Instantly share code, notes, and snippets.

@trinker
Created November 1, 2017 12:25
Show Gist options
  • Select an option

  • Save trinker/d288d83a2d5de16d2c670dd876d6baa3 to your computer and use it in GitHub Desktop.

Select an option

Save trinker/d288d83a2d5de16d2c670dd876d6baa3 to your computer and use it in GitHub Desktop.
Scraping Minimal Example w/ Robots.txt Checking
if (!require("pacman")) install.packages("pacman")
pacman::p_load(robotstxt, dplyr, xml2, rvest)
path <- 'https://www.fluentu.com/blog/english/basic-english-phrases/'
paths_allowed(path)
path %>%
xml2::read_html() %>%
rvest::html_nodes('h4') %>%
rvest::html_text() %>%
{gsub('^\\S+\\s+', '', .)} %>%
paste(collapse = '\n') %>%
cat()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment