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 cj
object. Here is a simple example after opening reddit:
In [40]: for c in cj:
....: print c.name, c.value
....:
....:
reddit_first %7B%22firsttime%22%3A%20%22first%22%7D
I haven't transferred them to Selenium in that method before, but I assume you can use the structure you have outlined above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With