I am using python urllib2 and a cookiejar to access a website. The last page of the site is too complex to handle with urllib2 (it uses javascript and frames), so I’d like to open it using Selenium, but I need to transfer my cookies over to selenium before I can proceed.
I have my cookiejar setup as follows
cj = cookielib.CookieJar()
Is there some way to iterate over this, and output each cookie? It looks like I can set the cookies in selenium using:
Cookie cookie = new Cookie("key", "value");
driver.manage().addCookie(cookie);
You can actually just iterate over the
cjobject. Here is a simple example after opening reddit:I haven’t transferred them to Selenium in that method before, but I assume you can use the structure you have outlined above.