# OLD WAY # f = urllib2.urlopen(url, urllib.urlencode(params)) # New way with cookies! COOKIEFILE = 'cookies.lwp' # Change this to your cookie jar filename urlopen = urllib2.urlopen cj = cookielib.LWPCookieJar() # If there's a cookie jar file, open it if os.path.isfile(COOKIEFILE): cj.load(COOKIEFILE) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) f = urlopen(urllib2.Request(url, urllib.urlencode(params))) # Now get the answer or whatever you want to do next.. response = urllib2.urlopen(Request) # Don't forget to save the cookies to a file when you're done!