/course-materials/application-exercises/ae-09-uoeart-functions/01-individual-pieces.R
https://github.com/rstudio-education/datascience-box · R · 44 lines · 18 code · 15 blank · 11 comment · 0 complexity · 29ba637a2a4de8649890d17bd406e76b MD5 · raw file
- # load packages ----------------------------------------------------------------
- library(tidyverse)
- library(rvest)
- # first url --------------------------------------------------------------------
- ## set url ----
- first_info_url <- "https://collections.ed.ac.uk/art/record/22024?highlight=*:*"
- ## read page at url ----
- page <- read_html(first_info_url)
- ## scrape headers ----
- headers <- page %>%
- html_nodes("th") %>%
- html_text()
- ## scrape values ----
- values <- page %>%
- html_nodes("td") %>%
- html_text() %>%
- str_squish()
- ## put together in a tibble and add link to help keep track ----
- tibble(headers, values) %>%
- pivot_wider(names_from = headers, values_from = values) %>%
- add_column(link = first_info_url)
- # second url --------------------------------------------------------------------
- ## set url ----
- second_info_url <- "___"
- ___
- # third url --------------------------------------------------------------------
- ## set url ----
- third_info_url <- "___"
- ___