I am new to the world of r, I have not been able to skip the URLs that according to the website show: “ 504 error That content doesn't seem to exist…” There exists a list of people on the website that I need to get the table and also information in the nested links for each of those people. But only the webpage is giving 504 error for 1 person (84th person) so I would like to know how I can skip the page so that in my data frame the webpage for that specific person to be marked as non-existent. Thanks for your help.
here is my code:
***library(rvest)
library(dplyr)
library(stringr)
library(jsonlite)
library(readr)
url="https://www.barrons.com/advisor/report/top-financial-advisors/100?id=/100/2022&type=ranking_tables"
doc = fromJSON(txt=url)
result = doc$data$data
print(result)
link=str_split_fixed(doc$data$data$Advisor, "\'", n = Inf)
advisor_links= link[,4]
for (i in 1: length(advisor_links)){
name_link=advisor_links[i]
advisor_page= read_html(name_link)
position= advisor_page%>% html_nodes(".BarronsTheme--lg--18rTokdG p:nth-child(1)")%>% html_text()%>% paste(collapse = ",")
print(position)
}***