views:

35

answers:

0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2
import urllib
import httplib
import Cookie
import cookielib

Login = 'user'
Password = 'password'
Domain = 'inbox.ru'
Auth = 'https://auth.mail.ru/cgi-bin/auth'


cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'Login' : Login,
                               'Domain' :Domain,  
                               'Password' : Password
                               })

opener.open('https://auth.mail.ru/cgi-bin/auth', login_data)
resp = opener.open('https://auth.mail.ru/cgi-bin/auth').read()
print resp.decode('cp1251') #output page in cp1251

When script sucessfully executed i see in print resp.decode('cp1251') my page with auth. But when a try to request another page for example http://my.mail.ru i see autorization request.

How i can use cookie with another page?