Skip to content

Instantly share code, notes, and snippets.

@virtualanup
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtualanup/7c8dcd0d2f73ea25bde2 to your computer and use it in GitHub Desktop.
Save virtualanup/7c8dcd0d2f73ea25bde2 to your computer and use it in GitHub Desktop.
Automatically cast votes in nepalspeaks.com
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