import urllib import urllib2 import hashlib import random import re TRASHMAIL_URL = 'https://www.trashmail.net/' FIND_NEW_EMAIL = \ re.compile(r'Your new email redirection address is: (.*?) ') def GetTrashMailAddress(redirect_to): values = dict( form_source=hashlib.md5(str(random.random())).hexdigest()[:8], form_dest=redirect_to, form_nb_redirections='30', form_expire_days='30', form_whitelisting='0', delete_msg_chk='1', lang='en', create_submit='Create disposable email address') data = urllib.urlencode(values) req = urllib2.Request(TRASHMAIL_URL, data) response = urllib2.urlopen(req) return FIND_NEW_EMAIL.search(response.read()).group(1)