1
resposta

Erro ao executar código

Executei o seguinte codigo

 while (ano_mes_corrente  <= 201709) {
  site <- paste("http://www.nuforc.org/webreports/ndxe", as.character(ano_mes_corrente), ".html")
  site <- gsub (" ", "", site)
  html2 <- get(site)
  parsed <- suppressMessages(htmlParse(html2, asText=TRUE))
  tableNodes <- getNodeSet(parsed, "//table")
  tb <- readHTMLTable(tableNodes[[1]])
  df_OVNI <- rbind(df_OVNI,tb)
  if (mes_corrente == 12)
  {
      mes_corrente <- 1
      ano_corrente <- ano_corrente + 1
      ano_mes_corrente <- (ano_corrente * 100) + mes_corrente
  }
  else
  {
    mes_corrente <- mes_corrente + 1
    ano_mes_corrente <- ano_mes_corrente + 1 
  }
  print(ano_mes_corrente)
}

Porém obtenho o seguinte erro:

Error in get(site) : 
  object 'http://www.nuforc.org/webreports/ndxe199710.html' not found

Já acessei esse link e está ok

1 resposta

Acredito que o problema esteja na função get. Uma solução é usar a função getURLContent do pacote RCurl no lugar da função get.

install.packages("RCurl")

library(RCurl)

html2 <- getURLContent(site)

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software