Warm tip: This article is reproduced from stackoverflow.com, please click
r url

Downloading data from URL in R

发布于 2020-03-29 21:00:30

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.

Questioner
Nellicopter
Viewed
48
anddt 2020-01-31 18:35

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.