[R] downloading web content

Duncan Temple Lang dtemplelang at ucdavis.edu
Tue Jul 23 16:06:17 CEST 2013


Hi Daisy

 Use getURLContent() rather than getURL().
The former handles binary content and this appears to be a zip file.

You can write it to a file or read its contents directly in memory, e.g

  library(RCurl)
  z = getURLContent("http://biocache.ala.org.au/ws/occurrences/download?q=Banksia+ericifolia")
  attributes(z)

  library(Rcompression)
  ar = zipArchive(z)
  names(ar)
  getZipInfo(ar)
  ar[["data.csv"]]
  dd = read.csv(textConnection(ar[["data.csv"]]))

  D.




On 7/23/13 2:59 AM, Daisy Englert Duursma wrote:
> Hello,
> I am trying to use R to download a bunch of .csv  files such as:
> 
> http://biocache.ala.org.au/ws/occurrences/download?q=Banksia+ericifolia
> 
> I have tried the following and neither work:
> 
> a<- getURL("
> http://biocache.ala.org.au/ws/occurrences/download?q=Banksia+ericifolia")
> 
> Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) :
>   embedded nul in string:
> and
> 
> a<-httpPOST("
> http://biocache.ala.org.au/ws/occurrences/download?q=Banksia+ericifolia")
> 
> Error: Internal Server Error
> 
> 
> Any help would be appreciated.
> 
> Daisy
>



More information about the R-help mailing list