Hi, I want to be able to authenticate to a website and then access some of the private pages in that site. I've looked at some examples and tutorials but I can't get it to work.
For example, I want to access https://www.billmonk.com/home which is available only after authentication. Here's the code I'm using:
url = 'https://www.billmonk.com/home'
values = {'usercontact' : '[email protected]',
'password' : 'somepass'}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
response = opener.open(req)
the_page = response.read()
This doesn't seem to be working. I always get a page with a "You must be logged in to access this page" page.
Am I missing something obvious?
Thanks!