Post request using cookies with cURL, RCurl and httr

后端 未结 3 675
陌清茗
陌清茗 2021-02-06 16:23

In Windows cURL I can post a web request similar to this:

curl  --dump-header cook.txt ^
  --data \"RURL=http=//www.example.com/r&user=bob&password=hell         


        
3条回答
  •  梦毁少年i
    2021-02-06 16:39

    Here is a way to create a post request, keep and reuse the resulting cookies with RCurl, for example to get web pages when authentication is required :

    library(RCurl)
    curl <- getCurlHandle()
    curlSetOpt(cookiejar="/tmp/cookies.txt", curl=curl)
    postForm("http://example.com/login", login="mylogin", passwd="mypasswd", curl=curl)
    getURL("http://example.com/anotherpage", curl=curl)
    

提交回复
热议问题