4

Is there a R library similar to pickle python library?

I'm doing some browsing with Selenium webdriver and I would like to save all cookies at the end of the session and reuse them in the next session. I have thought about implementing in R the equivalent to this question.

Can it be done with RCurl?

Mario M.
  • 802
  • 11
  • 26
  • You could use a specific profile for your process and keep it across sessions which should keep the cookies - https://stackoverflow.com/a/55996117/4779501 – Bob Aug 30 '19 at 08:12
  • @Bob I work with a virtual cloud machine (debian) where I only use selenium. Should I have any directory with browser information? I have never synchronized my account with chromedriver. Very useful link! – Mario M. Sep 03 '19 at 10:09
  • Sorry, dunno about the mechanics of chrome account synchronisation or chrome on linux offhand - I imagine locating the local profile dir should be the same. For the linked (local profile) method to work you'd obviously need to be creating your VM, launching chrome, finding the then profile, saving the VM and thereafter creating the VM each time from the state saved when you last shut it down. .... – Bob Sep 03 '19 at 10:49
  • ... Alternatively, if using a fresh VM each time I imagine having selenium do what you do to log in to an existing synchronised browser account on a new pc should do the (cookie) trick without having to tell selenium which profile to use - I'd try that ; sync on a normal pc then automate logging into that account on the fresh VM. – Bob Sep 03 '19 at 10:49

1 Answers1

-1

Get All Cookies – To get all the cookies from a particular browsing session. In first two examples, we have called a method to get all the cookies. The Method used is “getCookies()”, this method returns a Set of cookies. Using enhanced for-loop we can iterate over all the cookies and then can get all the attribute. See the example below:

Set<Cookie> cookieL = Driver.manage().getCookies();
for(Cookie temp_cookie : cookieL ){
System.out.println("Name of the cookie : "+temp_cookie.getName()+
" and its value : "+ temp_cookie.getValue());
}
PiyuSh
  • 15
  • 4