Linked Questions

Popular Questions

Scrape R For Loop - getting letter range A through Z for i

Asked by At

I'm trying to scrape the speakers for this year's SXSW: https://schedule.sxsw.com/2019/speakers/alpha/A

The end of the link has an A, but it goes through Z (like add a B, or a C, etc., to the end of the link.

Here's my attempt:

library(RCurl)
library(httr)
library(rvest)
library(tidyverse)

sxsw <- 'https://schedule.sxsw.com/2019/speakers/alpha/A'
page <- read_html(sxsw)

for (i in length(LETTERS)) {

    sxsw <- paste0('https://schedule.sxsw.com/2019/speakers/alpha/',  LETTERS[i])

    names <- page %>% 
     html_nodes(".px1 a") %>% 
     html_text()

}

I'm simply trying to append the entire range, so it returns all of the speaker names. If you take the names vector out of the loop, and run it, it pops up with all of the A names. I think this is a quick fix - think it has something to do with LETTERS. Thanks

Related Questions