import http.cookiejar, urllib.request, urllib.error, urllib.parse, os, pickle
if os.path.isFile('./cookies.txt'):
    cj = pickle.load(open('./cookies.txt', 'rb'))
else:
    cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
r = opener.open('http://example.com/')
pickle.dump(cj, open('./cookies.txt', 'wb'))
Файлы cookie с urllib2 и PyWebKitGtk