0

I used this code until recently

urlx <- "https://bank.gov.ua/NBUStatService/v1/statdirectory/key?start=20201117&end=20220223"
temp <- getURL(urlx, ssl.verifyPeer=FALSE)
xmltbl <- xmlTreeParse(temp, useInternal = TRUE)
xmltbl <- xmlToDataFrame(xmltbl)

Now, I have an error message on getURL function Error in function (type, msg, asError = TRUE) : error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

What is the best substitute in this situation?

Alex
  • 161
  • 6
  • Hi Alex! I couldn't access your url. Does this answer your question? [R: convert XML data to data frame](https://stackoverflow.com/questions/33446888/r-convert-xml-data-to-data-frame) – jassis Feb 23 '22 at 12:48
  • Hi @jassis -- thank you very much for your suggestion! I will take a look at it. – Alex Feb 23 '22 at 14:48

1 Answers1

1
library(tidyverse)
library(xml2)

"https://bank.gov.ua/NBUStatService/v1/statdirectory/key?start=20201117&end=20220223" %>%
  read_xml() %>%
  as_list() %>%
  simplify() %>%
  map(enframe) %>%
  pluck("indicators") %>%
  pull(value) %>%
  map(function(row) {
    row %>%
      enframe() %>%
      unnest_longer(value, indices_include = FALSE) %>%
      pivot_wider()
  }) %>%
  bind_rows()
danlooo
  • 10,067
  • 2
  • 8
  • 22
  • Thanks! This solves my problem. – Alex Feb 23 '22 at 14:49
  • now I am having this error while running this code: `Error: The x argument to enframe() must be a vector, not externalptr.` How should I fix it? – Alex Feb 23 '22 at 19:58
  • Please verify that this error is reproducible using a clean environment `rm(list=ls())`. Are you using a different URL? My code runs fine. – danlooo Feb 24 '22 at 08:26