Skip to content

Instantly share code, notes, and snippets.

@dubsnipe

dubsnipe/titles.R

Created Nov 11, 2020
Embed
What would you like to do?
Extract title from a list of URLS
require(tidyverse)
require(rvest)
toolbox <- tibble(read.csv("toolbox.csv", header=T))
read_title <- function(x){
tmp <- read_html(x) %>% html_node("title") %>% html_text()
return(tmp)
}
titles <- vector()
for (i in 1:length(toolbox$url)){
tryCatch({
title_test <- read_title(toolbox$url[i])
titles[i] <- title_test
}, warning = function(w){
return(NA)
},
error = function(e) {
return(NA)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.