Guest

Karl

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