Don't like ads? PRO users don't see any ads ;-)

Untitled

By: heidi666 on Aug 8th, 2013  |  syntax: Python  |  size: 1.58 KB  |  hits: 59  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import mechanize
  2. import sys
  3. import time
  4.  
  5. br = mechanize.Browser()
  6.  
  7. def sendAid(formid, dest, amount)
  8.     for i in range(amount):
  9.         dest = br.open('http://bloc.name/stats.php?id=%(1)d' % {'1':dest})
  10.             br.form = list(br.forms())[formid]
  11.             br.submit()
  12.         print "Done."
  13.  
  14. print "\nWhat is your username?"
  15. username = str(raw_input("> "))
  16.  
  17. print "\nWhat is your password?"
  18. password = str(raw_input("> "))
  19.  
  20. print "\nLogging in..."
  21. loginresponse = br.open('http://bloc.name')
  22. #loginhtml = loginresponse.read()
  23. #loginsoup = BS(loginhtml)
  24. #for form in br.forms():
  25. #    print form
  26. br.form = list(br.forms())[0]
  27. br["username"] = username
  28. br["password"] = password
  29. br.submit()
  30. print "Done."
  31.  
  32. while True:
  33.  
  34.     print "\nWho would you like to send to?"
  35.     print "Enter numbers only of the destination country ID."
  36.     recipient = int(raw_input("> "))
  37.  
  38.     print "\nWhat would you like to send?"
  39.     print "Enter o for oil or m for money."
  40.     aidchoice = str(raw_input("> "))
  41.  
  42.     print "\nHow much would you like to send?"
  43.     print "Enter the amount of times you would have clicked."
  44.     amount = int(raw_input("> "))
  45.  
  46.    
  47.     if aidchoice == "o":
  48.         sendAid(5, recipient, amount)
  49.         print "Done."
  50.            
  51.     if aidchoice == "m":
  52.         sendAid(3, recipient, amount)
  53.         print "Done."
  54.        
  55.     print "\nWould you like to send more aid? y/n."
  56.     choice = raw_input("> ")
  57.     if choice == 'n':
  58.         print "\nHope this helped! Bye."
  59.         time.sleep(2)
  60.         sys.exit(0)
  61.     if choice == 'y':
  62.         pass