I am trying to detect whether logging into a web form creates a redirection or not. Right now this process is fairly slow:
import urllib, urllib2
def redirection_occurs(user, password, login_page_url ):
login_data = urllib.urlencode({
'username':user,
'password':password
})
data = urllib2.urlopen( login_page_url, login_data )
# Returns true if redirection occurs
return data.geturl() != login_page_url
What makes the whole thing slow is the call to urllib2.urlopen( login_page_url, login_data ), is there a way around this? I simply want to detect whether or not a redirection has occurred after a login.