
Karl
By: a guest on Oct 8th, 2008 | syntax:
Python | size: 0.77 KB | hits: 156 | expires: Never
#!/usr/bin/env python
import urllib2
import urllib
import os
num = 1000000 # The number of times to iterate
y = 0 # number of failed iterations
params = {}
params ={'server':'http%3A%2F%2Fcmsema.mtv.co.uk%2Fema2008%2Fxml%2Fvoting%2FquietVote.jhtml','voteFor':'274130150'}
params = urllib.urlencode(params)
for x in range(num + y):
os.system('cls')
print "Iterations: %s" % x,
print "Number of errors: %s" % y,
print "Votes: %s" % (x-y),
req = urllib2.Request(url='<http://ema.mtv.co.uk/assets/php/vote-proxy.php>', data=params)
try:
urllib2.urlopen(req)
except:
y+=1
print ' (error occured)'
else:
print
# num + y forces it loop as many iterations as it takes to get to num inspite
# of any errors