winxp, python 2.6.. сайт щас лежит(
import urllib2
class DumbProxyPasswordMgr:
def __init__(self):
self.user = self.passwd = None
def add_password(self, realm, uri, user, passwd):
self.user = user
self.passwd = passwd
def find_user_password(self, realm, authuri):
return self.user, self.passwd
def build_opener(self,cookieFile,proxy_addres=None,proxy_user=None,proxy_pass=None):
cj = cookielib.LWPCookieJar()
if os.path.isfile(cookieFile):
cj.load(cookieFile)
cookie_handler=urllib2.HTTPCookieProcessor(cj)
if proxy_addres!=None:
proxy= urllib2.ProxyHandler({"http" : "http://"+proxy_addres})
proxy_auth_handler = urllib2.ProxyBasicAuthHandler(DumbProxyPasswordMgr ())
proxy_auth_handler.add_password(None, None, proxy_user, proxy_pass)
opener = urllib2.build_opener(proxy,proxy_auth_handler,cookie_handler)
else:
proxy= urllib2.ProxyHandler()
opener = urllib2.build_opener(cookie_handler,proxy)
return opener,cj
build_opener(...)[0].open('HTTPS site')
build_opener[1].save(cookieFile)