-
-
Save anonymous/fb020f7b5c5638d3062f5cb4d636e546 to your computer and use it in GitHub Desktop.
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
from lxml import html | |
from lxml import etree | |
from time import sleep | |
import requests | |
import string | |
import random | |
def volunteer(firstname,lastname,comments): | |
url = 'http://www.yescalifornia.org/volunteer' | |
cali = requests.get(url) | |
searchtree = html.fromstring(cali.content) | |
element = searchtree.xpath("//meta[@name='csrf-token']")[0] | |
token = element.get('content') | |
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36', | |
'Referer':'http://www.yescalifornia.org/volunteer', | |
'Origin':'http://www.yescalifornia.org', | |
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' | |
} | |
phonenumber = ''.join(random.choice(string.digits) for _ in range(10)) | |
emailadd = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10)) + "@gmail.com" | |
address = ''.join(random.choice(string.digits) for _ in range(3)) + '' + ''.join(random.choice(string.ascii_uppercase) for _ in range(7)) + ' st' | |
whentocall = ''.join(random.choice(string.ascii_uppercase) for _ in range(10)) | |
payload = {'authenticity_token':token, | |
'return_to':'http://www.yescalifornia.org/volunteer', | |
'email_address':'', | |
'volunteer_signup[volunteer_type_ids][]':'1', | |
'volunteer_signup[volunteer_type_ids][]':'2', | |
'volunteer_signup[volunteer_type_ids][]':'3', | |
'volunteer_signup[volunteer_type_ids][]':'4', | |
'volunteer_signup[volunteer_type_ids][]':'5', | |
'volunteer_signup[volunteer_type_ids][]':'', | |
'volunteer_signup[first_name]':firstname, | |
'volunteer_signup[last_name]':lastname, | |
'volunteer_signup[email]':emailadd, | |
'volunteer_signup[email_opt_in]':'0', | |
'volunteer_signup[email_opt_in]':'1', | |
'volunteer_signup[mobile_opt_in]':'0', | |
'volunteer_signup[mobile_opt_in]':'1', | |
'volunteer_signup[phone_number]':phonenumber, | |
'volunteer_signup[phone_time]':'always', | |
'volunteer_signup[submitted_address]':address, | |
'volunteer_signup[availability]':whentocall, | |
'volunteer_signup[content]':comments, | |
'volunteer_signup[is_private]':'0', | |
'commit':'Save volunteer info' | |
} | |
r = requests.post('http://www.yescalifornia.org/forms/volunteer_signups', data=payload, headers=headers) | |
return r | |
if __name__ == "__main__": | |
firstname = raw_input('Enter first name: ') | |
lastname = raw_input('Enter last name: ') | |
comments = raw_input('Enter some comments : ^ ): ') | |
while True: | |
volunteer(firstname,lastname,comments) | |
sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment