Sto tentando di imparare come leggere in un file di accesso/zip che ha un URL https in R. Questo fa parte di un più ampio progetto di apprendimento della mappatura che sto intraprendendo per ramificarmi le mie abilità R sono state trovate HERE(collegherò anche questo post).Errore file zip in lettura in un https URL
Questo era il piano, ma ottengo un errore dal getURL e io non so perché:
require(RCurl)
NYSdemo <- getURL("https://reportcards.nysed.gov/zip/SRC2010.zip")
temp <- tempfile()
download.file(NYSdemo, temp)
data <- read.table(unz(temp, "a1.dat"))
unlink(temp)
ERRORE:
> NYSdemo <- getURL("https://reportcards.nysed.gov/zip/SRC2010.zip")
Error in function (type, msg, asError = TRUE) :
SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Come ho detto questa è una progetto di apprendimento in modo che molte delle tecniche che sto usando qui non mi siano affatto familiari.
Il file zip vero che sto cercando di scaricare è HERE
Forse questo non è in realtà un problema di programmazione, ma qualcosa di sbagliato con l'URL che non consente getURL per essere utilizzato su di esso.
Grazie in anticipo per le vostre idee e aiuto.
EDIT: ho tentato lo ssl.verifypeer ma ottenere un altro errore
> NYSdemo <- getURL("https://reportcards.nysed.gov/zip/SRC2010.zip",
+ ssl.verifypeer = FALSE)
Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) :
embedded nul in string: 'PK\003\004\024\0\0\0\b\0i[j>¶U#]tó\036\005\0 ÷- {And it continues}
>
EDIT 2: Per suggerimenti di Vincent
> NYSdemo <- getURL("http://reportcards.nysed.gov/zip/SRC2010.zip")
> download.file(NYSdemo, temp)
Error in download.file(NYSdemo, temp) : unsupported URL scheme
>
> NYSdemo <- getBinaryURL("https://reportcards.nysed.gov/zip/SRC2010.zip")
Error in function (type, msg, asError = TRUE) :
SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
>
> url.exists("https://reportcards.nysed.gov/zip/SRC2010.zip")
[1] FALSE #not sure why this is because it works to type into url bar of browser
Queste informazioni mi sta portando a credo che il problema sia qualcosa di strano nel file zip. Idee?
Il messaggio di errore indica che non è stato possibile verificare l'identità del sito Web. Puoi provare ad ignorare questi controlli sostituendo 'https'by' http' (ma la connessione diventa non sicura). Potrebbe anche essere necessario sostituire 'getURL' con' getBinaryURL'. –
@Vincent Zoonekynd Grazie per la risposta. Ho provato i tuoi suggerimenti (vedi EDIT 2) ma non ho avuto fortuna. –
Se non si dispone più di un messaggio di errore dopo 'getURL', ha funzionato e il contenuto del file si trova nella variabile' NYSdemo'. 'download.file' fa la stessa cosa di' getURL' (quindi non hai bisogno di entrambi), e si aspetta un URL come argomento: 'download.file (" http: // ... ")'. –