Advertisement
wandrake

Untitled

Feb 27th, 2012
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. #!/usr/bin/env python2.6
  2. # -*- coding: utf-8 -*-
  3. import urllib
  4. import urllib2
  5. from time import *
  6. # build opener with HTTPCookieProcessor
  7.  
  8. while 1:
  9.     sleep(1)
  10.    
  11.     o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
  12.     urllib2.install_opener( o )
  13.  
  14.     # assuming the site expects 'user' and 'pass' as query params
  15.     p = urllib.urlencode( { 'username': '', 'password': '', 'provider': 'LDAP UniPi' } )
  16.  
  17.  
  18.     # perform login with params
  19.     f = o.open( 'https://auth1.unipi.it/auth/perfigo_cm_validate.jsp',  p )
  20.     data = f.read()
  21.     f.close()
  22.  
  23.     p = urllib.urlencode( { 'username': '', 'password': '', 'provider': 'LDAP UniPi', 'remove_old': '1' } )
  24.  
  25.     # perform login with params
  26.     f = o.open( 'https://auth1.unipi.it/auth/perfigo_cm_validate.jsp',  p )
  27.     data = f.read()
  28.     f.close()
  29.     sleep(10000)
  30.  
  31.  
  32. # second request should automatically pass back any
  33. # cookies received during login... thanks to the HTTPCookieProcessor
  34. f = o.open( 'http://www.google.it' )
  35. data = f.read()
  36. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement