2012-03-09 44 views
1

我需要使用RCurl發送一個簡單的cookie。 的Cookie是 「AcceptDisclaimer = YES」 我試着這樣做:RCurl發送cookie

curl <- getCurlHandle() 
curlSetOpt(cookiejar='cookies.txt', curl=curl) 
resultingWebPage <- postForm(website, x = result, curl = curl) 

cookie.txt的包含AcceptDisclaimer = YES

然而,RCurl似乎並沒有發送cookie!

問候!

回答

3
cookie = 'cookiefile.txt' 
curl = getCurlHandle (cookiefile = cookie, 
         cookiejar = cookie, 
         useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en - US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" 
) 

# code to do something with web page 

rm(curl) 
gc() 

使用cookiefile將加載存儲在文件中的cookie。 使用cookiejar將使用臨時cookie

調用rm(curl)gc()將刪除捲曲會話,並導致被寫入到磁盤上的cookie文件。