Last active
December 27, 2015 13:09
-
-
Save shshank/7331265 to your computer and use it in GitHub Desktop.
This script adds votes on an online voting competition.
Makes use of the mailinator.com's free temporary emails to make twitter accounts.
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
#This script adds votes on the an online voting competition. | |
#Makes use of the mailinator.com's free temporary emails to make twitter accounts. | |
#REQUIREMENTS: | |
#file:: proxies.txt | |
# each line in the file must contain a proxy in the form: <ip>:<port> | |
# e.g. xxx.xxx.xxx.xxx:8080 | |
# | |
#Change the variable values:: | |
# band_page_id and password must be changed by the user to a value of their choice. | |
# voting site twitter login url and voting page url must be entered. (removed from the script to not make it public) | |
#USAGE: | |
#Just put the requirements in place and run the script by: | |
# python auto_voter.py 20 | |
# | |
# this will run the script without proxy where 20 will be the number of tries you want to make. | |
# python auto_voter.py 20 proxy | |
# | |
# this will run the script with proxy. | |
#It will ask you to solve the captcha if it encounters one. And wait for your input. | |
# if the account is created press enter in the terminal. | |
# enter 'n' if twitter account was not created. It will change the proxy and try again. | |
#The script will not try a failed proxy twice in a single run. | |
import time | |
import sys | |
from selenium import webdriver | |
from random import randint, choice | |
#change the band id to the band you want to vote for. | |
# the id can be found by inspecting the vote button of the band. | |
# the three digit number in "data-event_applied-id" attribute is the id. | |
band_page_id = 000 | |
#Common password for all the twitter accounts created. | |
password = '********' | |
#the urls for the the voting site. | |
voting_site_twitter_login_url = 'https://page_for_voting_site_twitter_login.com' | |
voting_page_url = 'https://voting_page_for_the_event.com' | |
def generate_name(first_names, last_names): | |
#generates a random name and username | |
name = choice(first_names) + ' ' +choice(last_names) | |
number = str(randint(100,9000)) | |
symbols = [''] | |
username = name.replace(' ', choice(symbols)) + number | |
email = username + '@spamgoes.in' | |
print username | |
return {'name':name, 'username':username, 'email':email} | |
def twitter_signup(br, name, email, username): | |
#signs up for twitter | |
br.get("https://twitter.com/signup") | |
elem = br.find_element_by_xpath("""//input[@name="user[name]"]""") | |
elem.send_keys(name) | |
time.sleep(2) | |
elem = br.find_element_by_xpath("""//input[@name="user[email]"]""") | |
elem.send_keys(email) | |
time.sleep(3) | |
elem = br.find_element_by_xpath("""//input[@name="user[user_password]"]""") | |
elem.send_keys(password) | |
time.sleep(2) | |
elem = br.find_element_by_xpath("""//input[@name="user[screen_name]"]""") | |
elem.send_keys(username) | |
time.sleep(2) | |
elem = br.find_element_by_xpath("""//input[@name="user[remember_me_on_signup]"]""") | |
elem.click() | |
time.sleep(2) | |
elem = br.find_element_by_xpath("""//input[@name="user[use_cookie_personalization]"]""") | |
elem.click() | |
time.sleep(5) | |
button = br.find_element_by_xpath("""//input[@name="submit_button"]""") | |
button.click() | |
time.sleep(10) | |
if br.current_url == 'https://twitter.com/welcome/intro': | |
print 'account created' | |
else: | |
get = raw_input("Please solve the captcha...") | |
if get == 'n': | |
raise Exception("Couldn't complete..") | |
def mts_vote(br): | |
br.get(voting_site_twitter_login) | |
elem = br.find_element_by_id('allow') | |
elem.click() | |
time.sleep(10) | |
br.get(voting_page_url) | |
vote = br.find_element_by_xpath("""//a[@data-event_applied-id="%s"]"""%(band_page_id)) | |
vote.click() | |
def get_proxy_profile(): | |
proxies = [] | |
with open('proxies.txt') as proxy_file: | |
lines=proxy_file.readlines() | |
for line in lines: | |
data = line.split(':') | |
proxy = data[0] | |
post = int(data[1]) | |
proxies.append([proxy, post]) | |
print proxies | |
cur_proxy = choice(proxies) | |
print cur_proxy | |
fp = webdriver.FirefoxProfile() | |
fp.set_preference("network.proxy.type", 1) | |
fp.set_preference("network.proxy.http", cur_proxy[0]) | |
fp.set_preference("network.proxy.http_port", cur_proxy[1]) | |
fp.set_preference("network.proxy.ssl", cur_proxy[0]) | |
fp.set_preference("network.proxy.ssl_port", cur_proxy[1]) | |
fp.update_preferences() | |
return fp | |
def get_done(): | |
#gets the list of usernames already worked with | |
done = [] | |
if os.path.isfile('done.txt'): | |
with open('done.txt') as f: | |
lines = f.readlines() | |
if len(lines)<2: | |
for line in lines[:-1]: | |
done += line.strip() | |
return done | |
else: | |
f = open('done.txt', 'w') | |
f.close() | |
bad_proxy = [] | |
#names taken from http://en.wikipedia.org/wiki/Category:Indian_given_names | |
first_names = ["Aakash", "Aaravamuthan", "Aarthi", "Aarya", "Aashika", | |
"Aashish", "Abha", "Abhas", "Abhigyan", "Abhijatya", "Abhilash", | |
"Abhinandan", "Abhinav", "Abhinay", "Abhinit", "Abhishek", "Adarsh", | |
"Adesh", "Adi", "Adipika", "Aditi", "Aditya", "Aishwarya", "Ajay", | |
"Ajey", "Ajith", "Ajeet", "Akhila", "Akhilesh", "Akshata", "Akshay", | |
"Alikesh", "Alpesh", "Amal", "Aman", "Amani", "Amar", "Ambar", "Amit", | |
"Amol", "Amulya", "Anant", "Ananthu", "Anindita", "Animesh", "Anirudh", | |
"Anish", "Anitha", "Anjana", "Anjali", "Anjan", "Anjana", "Anju", "Anjum", | |
"Ankan", "Ankita", "Anmol", "Annapoorna", "Anoop", "Anshul", "Anshuman", | |
"Anu", "Anubhuti", "Anup", "Anupam", "Anupama", "Anuradha", "Anurag", "Aparna", | |
"Apoorva", "Aravind", "Aravinda", "Archana", "Arihant", "Arindam", "Arjun", | |
"Arpita", "Arnav", "Arshad", "Arun", "Aruna", "Aravind", "Asawari", "Aseem", | |
"Asha", "Ashesh", "Ashish", "Ashu", "Ashvin", "Ashwath", "Ashwatthama", "Ashweeta", | |
"Ashwin", "Ashwini", "Aswini", "Atmajyoti", "Atul", "Atulya", "Ayush", "Avanindra", | |
"Avanish", "Avinash", "Azhagu", "Anbuselvam", "Anbu", "Athi", "Anbukarsan", "Anand", | |
"Ananda", "Anbarasi", "Anita", "Anusha", "Aravindra", "Avani", "Aviral", "Babita", | |
"Bandheka", "Babu", "Babul", "Bablu", "Bala", "Balaram", "Balram", "Banti", "Basanti", | |
"Beena", "Bhagya", "Bhagyashri", "Bhairavi", "Bhalchandra", "Bharani", "Bharat", | |
"Bharath", "Bharathi", "Bhargavi", "Bhaskar", "Bhaskara", "Bhavani", "Bhavna", | |
"Bhooma", "Bhoomika", "Bhoominathan", "Bhushan", "Bibek", "Billu", "Bikram", | |
"Bikshapathi", "Bimala", "Bina", "Bindu", "Bineeta", "Biran", "Bodhisatva", "Bhola", | |
"Chaitra", "Chandana", "Chandni", "Chandra", "Chandrakant", "Chandraprabha", | |
"Chandrashekhar", "Charu", "Chetan", "Chetana", "Chilkoja", "Chirasmita", "Chithra", "Chitrasen", | |
"Chudamani", "Damodar", "Deepa", "Deepika", "Deepti", "Deepak", "Deven", "Devendra", "Devi", | |
"Dhanalakshmi", "Dhanush", "Dhanya", "Dhara", "Dharani", "Dharma", "Dharshan", "Dharshini", | |
"Dhwani", "Dikpal", "Dilip", "Dimitri", "Dipa", "Dipti", "Divya", "Draupadi", "Divyajyoti", | |
"Faltu", "Fanishwar", "Fardeen", "Fatima", "Farheen", "Farooq", "Faisal", "Faraha", "Fangs", | |
"Feroz", "Gagana", "Gajalakshmi", "Gajanand", "Ganesh", "Ganesha", "Ganga", "Gauri", "Gayathri", | |
"Gayatri", "Geeta", "Geetika", "Girish", "Godavari", "Gopal", "Gopinath", "Govind", "Greisha", | |
"Grisha", "Padma", "Padmanabh", "Palak", "Pallavi", "Parag", "Paramjit", "Paras", "Parna", | |
"Parthasarathi", "Parvati", "Pompy", "Pooja", "Poornima", "Prabha", "Prachi", "Pradeep", | |
"Prafulla", "Pragati", "Pragya", "Prahlad", "Prajakta", "Prajna", "Prakash", "Pramila", | |
"Pramit", "Pramod", "Pran", "Pranav", "Pranay", "Pranil", "Praneel", "Prapanna", "Prarthna", | |
"Prasad", "Prasanna", "Prashant", "Prathap", "Pratibha", "Pratik", "Pratiksha", "Pratima", | |
"Pratyush", "Praveen", "Preetam", "Preethi", "Preeti", "Prem", "Prema", "Pritam", "Prithwish", | |
"Priya", "Priyadarshini", "Priyamvadha", "Priyanka", "Priysabratha", "Protima", "Purnima", | |
"Purnam", "Purvi", "Puganeshwary", "Puga"] | |
last_names = ["Sharma", "Pandey", "Panda", "Singh", "Agarwal", "Agrawal", "Kumar", "Shekhar", "Mishra", | |
"Thumbi", "Shankar", "Bubbar", "Jain", "Mahapatra", "Moharana", "Pandya", "Shikhar", "Hiradhar", | |
"Singhania", "Balbantray"] | |
def main(proxy=False): | |
if proxy: | |
proxy = get_proxy_profile() | |
while proxy in bad_proxy: | |
proxy = get_proxy_profile() | |
br = webdriver.Firefox(firefox_profile=proxy) | |
else: | |
br = webdriver.Firefox() | |
creds = generate_name(first_names, last_names) | |
while creds['username'] in get_done(): | |
print 'already done' | |
creds = generate_name(first_names, last_names) | |
try: | |
twitter_signup(br, creds['name'], creds['email'], creds['username']) | |
with open('done.txt', 'a') as f: | |
f.write(creds['username']+'\n') | |
mts_vote(br) | |
time.sleep(1) | |
except Exception, e: | |
if proxy: | |
bad_proxy.append(proxy) | |
print e | |
br.close() | |
if __name__ == '__main__': | |
proxy=True if sys.argv[2] == 'proxy' else False | |
[main(proxy) for i in range(sys.argv[1])] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment