0

I want to use functions from rvest package in loop (to extract part of html code from many pages). In lista_strona I have url of pages to be scraped. Without loop this works fine.

In loop I have an error

"Error in doc_parse_file(con, encoding = encoding, as_html = as_html, options = options) : Expecting a single string value: [type=character; extent=4]"

lista_stron<-read.csv("C:/Users/.../Desktop/R/rvest/X.csv", header = T )
for (a in lista_stron) {read_html(a)%>%html_nodes(".gray2 span")%>%html_text()}

What can I do to use this functions in loop?

charan kumar
  • 2,119
  • 2
  • 20
  • 26
  • 2
    The output of `read.csv()` is a data.frame, so you need to specify which column of `lista_stron` contains the url pages. – Pol Ferrando Aug 27 '18 at 11:45
  • Please add the output of `dput(lista_stron)` to your question. See more here https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1 – Tung Aug 27 '18 at 12:35
  • output of dput(lista_stron): structure(list(Strona = structure(c(2L, 3L, 4L, 1L), .Label = c("https://www.xx4", "https://www.xx2/", "https://www.xx3/", "https://www.xx/"), class = "factor")), class = "data.frame", row.names = c(NA, -4L) – Sebastian SEO Aug 27 '18 at 12:44

0 Answers0