Error reading uploaded html file using rvest in shiny

21 lượt xem
Chuyển tới thư đầu tiên chưa đọc

Prateek Arora

chưa đọc,
16:24:17 16 thg 8, 201816/8/18
đến manipulatr

I want to make a shiny app which uploads a html file which has xml in it. But when I upload this html file, it gives me an error

 

no applicable method for 'read_xml' applied to an object of class "data.frame"

 

The file can be read when run in a normal condition(non shiny app condition). My code is as follows:

library(shiny)
library
(rvest)
ui
<- fluidPage(
fileInput
(
  inputId
= "file_input",
 
"Upload file",
  multiple
= TRUE,
  accept
= ".html"
),
tableOutput
("table")
)

server
<- function(input, output) {
   getData
<- reactive({
   inFile
<- input$file_input
 
if (is.null(inFile)) {
   
return(NULL)
   
} else {
  inputdata
<- read_html(inFile)
}

})
output$table
<- renderTable({
getData
()
})
}
shinyApp
(ui = ui, server = server)

 

Reading answers online, I also tried to add a html_session for the same.



server <- function(input, output) {
getData <- reactive({
inFile <- input$file_input
if (is.null(inFile)) {
  return(NULL)
} else {
  html_session(inFile$datapath)
  inputdata <- read_html(inFile)
}

But then I get the following error:

 Warning: Error in curl::curl_fetch_memory: Port number ended with '\

Any idea how can I solve this problem?

Trả lời tất cả
Trả lời tác giả
Chuyển tiếp
0 tin nhắn mới