Friday, 15 February 2013

Python mechanize not using cookies between requests -



Python mechanize not using cookies between requests -

i'm trying login mechanize, session cookie, load protected page mechanize doesn't seem saving or re-using session. when seek load protected resource redirected login page. can see i'm doing wrong code below?

import mechanize import urllib import cookie import cookielib cookiejar=cookielib.lwpcookiejar() br = mechanize.browser() br.set_cookiejar(cookiejar) br.set_handle_robots(false) br.addheaders = [('user-agent', 'mozilla/5.0 compatible')] br.set_cookiejar(cookiejar) params = {'email_address': 'name@company.com', 'password':pass} info = urllib.urlencode(params) request = mechanize.request('/myloginpage', data=data) response = br.open(request) html = response.read() request = mechanize.request('/myprotectedpage') response = br.open(request)

at point response not info protected resource redirect login page

python mechanize

No comments:

Post a Comment