[R] RCurl cookiejar

Duncan Temple Lang dtemplelang at ucdavis.edu
Tue Aug 27 15:29:39 CEST 2013


Hi Earl

 The cookies will only be written to the file specified by the cookiejar option
when the curl handle is garbage collected.

 If you use

   rm(ch)
   gc()

the cookie.txt file should be created.

 This is the way libcurl behaves rather than something RCurl introduces.

 If you don't explicitly specify a curl handle in a request, the cookiejar
 option works as on expects because the implicit curl handle is destroyed
 at the end of the call and often garbage collection occurs.


  D.

On 8/24/13 11:01 PM, Earl Brown wrote:
> R-helpers,
> 
> When I use cURL in the Terminal:
> 
> curl --cookie-jar cookie.txt --url "http://corpusdelespanol.org/x.asp" --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:16.0) Gecko/20100101 Firefox/23.0" --location --include
> 
> a cookie file "cookie.txt" is saved to my working directory. However, when I try what I think is the equivalent command R with RCurl:
> 
> ch <- getCurlHandle(followlocation = T, header = T, useragent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:16.0) Gecko/20100101 Firefox/23.0")
> getURL(url = "http://www.corpusdelespanol.org/x.asp", cookiejar = "cookie.txt", curl = ch)
> 
> no cookie file is saved. 
> 
> What am I missing to reproduce in RCurl what I'm successfully doing in the Terminal?
> 
> Thank you for your time and help. Earl Brown
> 
> -----
> Earl K. Brown, PhD
> Assistant Professor of Spanish Linguistics
> Advisor, TEFL MA Program
> Department of Modern Languages
> Kansas State University
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>



More information about the R-help mailing list