Advertisement
wandrake

Untitled

Apr 29th, 2011
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #!/usr/bin/env python2.6
  2. # -*- coding: utf-8 -*-
  3. import urllib
  4. import urllib2
  5. # build opener with HTTPCookieProcessor
  6. o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
  7. urllib2.install_opener( o )
  8.  
  9. p = urllib.urlencode( { 'username': 'tuouser', 'password': 'tuapass', 'provider': 'LDAP-Studenti' } )
  10.  
  11.  
  12. # perform login with params
  13. f = o.open( 'https://auth3.unipi.it/auth/perfigo_cm_validate.jsp',  p )
  14. data = f.read()
  15. f.close()
  16.  
  17. p = urllib.urlencode( { 'username': 'tuouser', 'password': 'tuapass', 'provider': 'LDAP-Studenti', 'remove_old': '1' } )
  18.  
  19. # perform login with params
  20. f = o.open( 'https://auth3.unipi.it/auth/perfigo_cm_validate.jsp',  p )
  21. data = f.read()
  22. f.close()
  23.  
  24. # second request should automatically pass back any
  25. # cookies received during login... thanks to the HTTPCookieProcessor
  26. f = o.open( 'http://www.google.it' )
  27. data = f.read()
  28. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement