1

I'm building a Shiny App in R and I'm trying to scrub off the web information about the user's selected Pokemon, but I keep running into the problem of 'Error: SLL certificate problem' when trying to use read_html()

ui:

  sidebarPanel(
        ui <- fluidPage(
            selectInput(inputId = "pokemon1", 'Choose a Pokémon:', c(Pokemon$Name)))),
   mainPanel(
             verbatimTextOutput("value"))
                                
                                

And then the Server:

server <- function(input, output) {
  
  output$value <- renderPrint({
    pokemon <- input$pokemon1
    URLpokemon <- paste(c("https://bulbapedia.bulbagarden.net/wiki/", pokemon,"_(Pok%C3%A9mon)"), collapse="")
    # Read and parse HTML file
    pokemonSummary1 <- URLpokemon%>%
      read_html() %>% # R please help me read this HTML code
      html_nodes("p")%>% # type of HTML object
      .[[1]]%>%
      html_text()
    pokemonSummary2 <- URLpokemon%>%
      read_html() %>% # R please help me read this HTML code
      html_nodes("p")%>% # type of HTML object
      .[[2]]%>%
      html_text()
    pokemonSummary3 <- URLpokemon%>%
      read_html() %>% # R please help me read this HTML code
      html_nodes("p")%>% # type of HTML object
      .[[3]]%>%
      html_text()
    
    textAlmanac <- paste(c(pokemonSummary1,pokemonSummary2,pokemonSummary3), collapse=" ")
    
    paste(textAlmanac)
  })

I'm using this data set: https://gist.github.com/armgilles/194bcff35001e7eb53a2a8b441e8b2c6

and I have no idea where this error is coming from?

2 Answers2

0

Since you are trying to scrape from a website using a certificate (HTTPS), you will need to use the R package httr. More explanation can be found here: How to webscrape secured pages in R (https links) (using readHTMLTable from XML package)?

dkreeft
  • 642
  • 5
  • 17
0

I used your code above (slightly edited) and came out with this minimal working example which works on my machine...

global.R

library(shiny)
library(magrittr)
library(rvest)

Pokemon <- read.csv('pokemon.csv', stringsAsFactors = FALSE)

ui.R

ui <- fluidPage(
    sidebarPanel(
        selectInput(inputId = "pokemon1", 'Choose a Pokemon:', c(Pokemon$Name))),
    mainPanel(
        verbatimTextOutput("value"))
)

server.R

server <- function(input, output) {

    output$value <- renderPrint({
        pokemon <- input$pokemon1
        URLpokemon <- paste(c("https://bulbapedia.bulbagarden.net/wiki/", pokemon,"_(Pok%C3%A9mon)"), collapse="")
        # Read and parse HTML file
        pokemonSummary1 <- URLpokemon%>%
            read_html() %>% # R please help me read this HTML code
            html_nodes("p")%>% # type of HTML object
            .[[1]]%>%
            html_text()
        pokemonSummary2 <- URLpokemon%>%
            read_html() %>% # R please help me read this HTML code
            html_nodes("p")%>% # type of HTML object
            .[[2]]%>%
            html_text()
        pokemonSummary3 <- URLpokemon%>%
            read_html() %>% # R please help me read this HTML code
            html_nodes("p")%>% # type of HTML object
            .[[3]]%>%
            html_text()

        textAlmanac <- paste(c(pokemonSummary1,pokemonSummary2,pokemonSummary3), collapse=" ")

        paste(textAlmanac)
    })
}

I get the following page

I hope this helps

Eli Berkow
  • 2,628
  • 1
  • 12
  • 22