Hi Python gurus! Please help me how I can login to this page: https://www.boplats.se/user/login_hs.aspx?ReturnUrl=/HSS/Default.aspx
I tried these two codes, but I don't seem to be successfull at all. (Both gave same result.) Many many thanks, /Ben ----------- import urllib2,urllib,cookielib urll = "https://www.boplats.se/user/login_hs.aspx?ReturnUrl=/HSS/ Default.aspx" cj = cookielib.CookieJar() opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(cj)) data = urllib.urlencode ( { "username" : "myuser" , "password" :"mypass" } ) fp = opener.open( urll,data ) print fp.read() ------------ OR th second code ------------ import urllib2 as __urllib2 import base64 as __base64 #-------------------------------------------------------------- def download_file(url, webuser = None, webpass = None): request = __urllib2.Request(url) if webuser: base64string = __base64.encodestring('%s:%s' % (webuser, webpass))[:-1] request.add_header("Authorization", "Basic %s" % base64string) htmlFile = __urllib2.urlopen(request) htmlData = htmlFile.read() htmlFile.close() return htmlData #-------------------------------------------------------------- if __name__ == "__main__": # Test #***************************** __url = "https://www.boplats.se/user/login_hs.aspx?ReturnUrl=/HSS/ Default.aspx" __webuser = "myuser" __webpass = "mypass" print download_file(__url, __webuser, __webpass) #***************************** -- http://mail.python.org/mailman/listinfo/python-list