Nellicopter
Nellicopter

Reputation: 83

Downloading data from URL in R

I would like to download data from the following url 'https://ghoapi.azureedge.net/api/HWF_0006'.

I have tried this:

library(RCurl)
content <- getURL ('https://ghoapi.azureedge.net/api/HWF_0006')

And this is the error message that i got:

> content <- getURL ('https://ghoapi.azureedge.net/api/HWF_0006')
Error in function (type, msg, asError = TRUE)  : 
  Failed to connect to ghoapi.azureedge.net port 443: Timed out

Any ideas on how to solve this?

Thank you very much,

N.

Upvotes: 0

Views: 376

Answers (2)

anddt
anddt

Reputation: 1651

As far as I can tell, it looks like you're trying to read a JSON file. You can easily do that with jsonlite package:

library(jsonlite)

df <- fromJSON('https://ghoapi.azureedge.net/api/HWF_0006')

And parse it/unnest it as you please.

Upvotes: 1

Ronak Shah
Ronak Shah

Reputation: 389235

Try using rvest

library(rvest)
url <- 'https://ghoapi.azureedge.net/api/HWF_0006'

data_list <- read_html(url) %>% html_text() %>% jsonlite::fromJSON()

data_list[[2]] returns a dataframe and maybe that is what you are looking for.

Upvotes: 1

Related Questions