cookie_file = “/tmp/netcraft_cookie.txt”
global_cookie = cookielib.MozillaCookieJar(cookie_file)
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(global_cookie))
pq = PyQuery(opener.open(sso_url).read())
csrf_token = pq(“input[name=’csrf_token’]”).attr(“value”)
destination = pq(“input[name=’destination’]”).attr(“value”)
print “get page \n csrf_token : %s \n destination: %s ” % (csrf_token,destination)
global_cookie.save(ignore_discard=True, ignore_expires=True)