I am attempting to build a URL in R to do some web scraping. When my URL needs to use a "%" I am getting an error. Below is an example of what one iteration of my code is trying to do. Below is also what my full URL looks like when it has been built:
I have tried using \ to escape the % symbol, I have also referenced the following links but have not been able to make them successfully work for my situation:
URL Escaping in R How do I deal with special characters like \^$.?*|+()[{ in my regex?
link <- "https://247sports.com/Season/"
year<-2018
team<-"PrepSchool"
year_url <- sprintf(link, year)
year_url2 <- str_c(year_url, "-Football/CompositeRecruitRankings/?ViewPath=~%2FViews%2FSkyNet%2FPlayerSportRanking%2F_SimpleSetForSeason.ascx&InstitutionGroup=%s")
team_url <- sprintf(year_url2, team)
team_url2<-str_c(team_url,"&page=%i")
When I run this I get the following error:
Error in sprintf(year_url2, team) : invalid format '%2FVi'; use format %s for character objects
Edited URL