Learn R Programming

ralger (version 2.3.0)

tidy_scrap: Website Tidy scraping

Description

This function is used to scrape a tibble from a website.

Usage

tidy_scrap(link, nodes, colnames, clean = FALSE, askRobot = FALSE)

Value

a tidy data frame.

Arguments

link

the link of the web page to scrape

nodes

the vector of HTML or CSS elements to consider, the SelectorGadget tool is highly recommended.

colnames

the names of the expected columns.

clean

logical. Should the function clean the extracted tibble or not ? Default is FALSE.

askRobot

logical. Should the function ask the robots.txt if we're allowed or not to scrape the web page ? Default is FALSE.

Examples

Run this code
# \donttest{
# Extracting imdb movie titles and rating
link     <- "https://www.imdb.com/chart/top/"
my_nodes <- c("a > h3.ipc-title__text", "span.ratingGroup--imdb-rating")
names    <- c("title", "rating")
tidy_scrap(link, my_nodes, names)
# }

Run the code above in your browser using DataLab