Last active
August 29, 2015 14:09
-
-
Save virtualanup/7c8dcd0d2f73ea25bde2 to your computer and use it in GitHub Desktop.
Automatically cast votes in nepalspeaks.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
from urllib.parse import urlencode | |
while True: | |
try: | |
id = int(input("Enter question ID ")) | |
break | |
except: | |
print("Enter a valid ID") | |
while True: | |
try: | |
selection = int(input("Enter Your Selection ")) | |
break | |
except: | |
print("Enter a valid selection") | |
while True: | |
try: | |
novotes = int(input("Enter number of votes ")) | |
if novotes > 0: | |
break | |
finally: | |
print("Enter a valid number") | |
print(selection," for question ",id) | |
url = "http://nepalspeaks.com/addform.php" | |
for i in range(0,novotes): | |
try: | |
print(i,"th vote") | |
params = { | |
"qname": str(id), | |
"think": str(selection), | |
"submit": "Vote", | |
} | |
data = urlencode(params).encode("ASCII") | |
conn = urllib.request.urlopen(url, data=data) | |
data = conn.read() | |
# print(data) | |
except: | |
print("Error occured") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment