r-lib / httr

httr: a friendly http package for R
https://httr.r-lib.org
Other
985 stars 1.99k forks source link

httr::GET request setting multiple cookies #668

Closed guillecarc closed 4 years ago

guillecarc commented 4 years ago

How can i send multiple cookies using httr::GET?

I have not been able to find a solution in the documentation.

GET("https://www.instagram.com/bmw/",
           set_cookies(cookies))

cookiescomes from cookies.txt and it looks as follow (this is a dummy file):

# HTTP Cookie File downloaded with cookies.txt by Genuinous @genuinous
# This file can be used by wget, curl, aria2c and other standard compliant tools.
# Usage Examples:
#   1) wget -x --load-cookies cookies.txt "https://www.instagram.com/bmw/"
#   2) curl --cookie cookies.txt "https://www.instagram.com/bmw/"
#   3) aria2c --load-cookies cookies.txt "https://www.instagram.com/bmw/"
#
www.instagram.com   FALSE   /   FALSE   4745854048  ig_cb   1
.instagram.com  TRUE    /   TRUE    1905518849  ig_did  BB816137-6efC3-4150-A122-35026E5E2576
.instagram.com  TRUE    /   TRUE    1905518847  mid Xsfl_ww2EAAH-lfBCRL_nzY37GMpP
.instagram.com  TRUE    /   TRUE    1625155221  fbm_12402457428er414    base_domain=.instagram.com
.instagram.com  TRUE    /   TRUE    1627482258  csrftoken   k3R1XBvweqvdcsZAlzIJDqiu8kb3ZiGo2
.instagram.com  TRUE    /   TRUE    1603808658  ds_user_id  224527347
.instagram.com  TRUE    /   TRUE    1627542917  sessionid   2245256307%3A62lWRz4SCFsc4p%3A5
.instagram.com  TRUE    /   TRUE    1596611717  shbid   14047
.instagram.com  TRUE    /   TRUE    1596611717  shbts   1596206916.5382576
.instagram.com  TRUE    /   TRUE    0   rur ATN
.instagram.com  TRUE    /   TRUE    0   urlgen  "{\"2001:16b8:4632:a200:852b:3254:106:83f4\": 8881}:1k0n0D:YjgA4LjfOC6KIibYZrcnyyr7YRk"

Is there a way to process the cookie.txt file into the set_cookies function? I could only set 1 cookie at a time.