24.5 Example: Quarantine Zine Club

  • Task is to create a spreadsheet where we have the titles of the zines, their authors, the links to download the zines, and the first social media link of the authors.
  • Used xpath here, but was not discussed in book.
  • The code chunk below should work but gives an error when processed at Github repo of bookclub-r4ds, but it works on my machine. I have yet to figure out why.
url <- "https://quarantinezineclub.neocities.org/zinelibrary"
html <- read_html(url) 
zinelib <- tibble(authors = html |> html_elements("#zname") |> html_text2(), 
       titles = html |> html_elements("#libraryheader") |> html_text2(),
       pdflink = html |> 
  html_elements(xpath = "//div[@class='column right']") |> html_element("a") |> html_attr("href"),
       mark = 2:156
       )
get.first.social <- function(num)
{
  return(html |> html_elements(xpath = paste("/html/body/div[2]/div[", num, "]/div[2]/a[1]", sep = ""))|> html_attr("href"))
}
zinelib <- zinelib |> mutate(
  pdflink = paste("https://quarantinezineclub.neocities.org/", pdflink, sep = ""),
  social1 = get.first.social(mark)) |> select(-mark)
zinelib