Using a session cookie from selenium in urllib2
I was able to overcome this problem by using the requests
library instead. I iterated over the cookies from selenium, and then passed them in a simple dictionary with name:value
pairs.
all_cookies = self.driver.get_cookies()cookies = {} for s_cookie in all_cookies: cookies[s_cookie["name"]]=s_cookie["value"]r = requests.get(my_url,cookies=cookies)
You may try as below.
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))urllib2.install_opener(opener)f_opener = opener.open(url_that_requires_a_logged_in_user)content = f_opener.read()