Ejemplo n.º 1
0
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            email = form.cleaned_data['email']
            client = EmailHunterClient(
                '18c8c0f231fb70655152e81e54bb37004a304c0a')
            if client.exist(email):
                form.save()
                return redirect('/account')
    else:
        form = RegistrationForm()

        args = {'form': form}
        return render(request, 'accounts/reg_form.html', args)
Ejemplo n.º 2
0
def search(client: EmailHunterClient,
           domain,
           offset,
           type_,
           print_header=True,
           is_file_output=False):
    if is_file_output:
        header = 'domain,email,type,sources'
        line_format = '{},{},{},{}'
    else:
        header = 'Domain\tEmail\tType\tSources'
        line_format = '{}\t{}\t{}\t{}'

    try:
        emails = client.search(domain, offset, type_)
    except Exception as e:
        print('Error during search request: {}'.format(e))
    else:
        for data in emails:
            email = data['value']
            type_ = data['type']
            sources = reduce_sources(data['sources'])

            if print_header:
                print(header)
                print_header = False

            print(line_format.format(domain, email, type_, sources))
Ejemplo n.º 3
0
    def __init__(self):
        config = configparser.ConfigParser()
        cwd = os.path.abspath(automated_bot.__path__[0])
        file_path = os.path.join(cwd, 'settings.ini')
        config.read(file_path)
        self._config = config

        fake = Faker()
        fake.add_provider(internet)

        self._fake = fake
        self._email_hunter_client = EmailHunterClient(
            config.get('bot', 'EMAIL_HUNTER_KEY'))
Ejemplo n.º 4
0
def exist(client: EmailHunterClient, email, print_header=True, is_file_output=False):
    try:
        exist_, sources = client.exist(email)
    except Exception as e:
        print('Error during exist request: {}'.format(e))
    else:
        if is_file_output:
            if print_header:
                print('email,exist,sources')

            sources = reduce_sources(sources)
            print('{},{},{}'.format(email, exist_, sources))
        else:
            print('Email:\t{}'.format(email))
            print('Exist:\t{}'.format(exist_))
            print('Sources:\t{}'.format(json.dumps(sources, indent=2)))
Ejemplo n.º 5
0
def generate(client: EmailHunterClient, domain, first_name, last_name, print_header=True, is_file_output=False):
    try:
        email, score = client.generate(domain, first_name, last_name)
    except Exception as e:
        print('Error during request: {}'.format(e))
    else:
        if is_file_output:
            if print_header:
                print('domain,first_name,last_name,email,score')

            print('{},{},{},{},{}'.format(domain, first_name, last_name, email, score))
        else:
            print('Domain:\t{}'.format(domain))
            print('First Name:\t{}'.format(first_name))
            print('Last Name:\t{}'.format(last_name))
            print('Email:\t{}'.format(email))
            print('Score:\t{}'.format(score))
Ejemplo n.º 6
0
def exist(client: EmailHunterClient,
          email,
          print_header=True,
          is_file_output=False):
    try:
        exist_, sources = client.exist(email)
    except Exception as e:
        print('Error during exist request: {}'.format(e))
    else:
        if is_file_output:
            if print_header:
                print('email,exist,sources')

            sources = reduce_sources(sources)
            print('{},{},{}'.format(email, exist_, sources))
        else:
            print('Email:\t{}'.format(email))
            print('Exist:\t{}'.format(exist_))
            print('Sources:\t{}'.format(json.dumps(sources, indent=2)))
Ejemplo n.º 7
0
def generate(client: EmailHunterClient,
             domain,
             first_name,
             last_name,
             print_header=True,
             is_file_output=False):
    try:
        email, score = client.generate(domain, first_name, last_name)
    except Exception as e:
        print('Error during request: {}'.format(e))
    else:
        if is_file_output:
            if print_header:
                print('domain,first_name,last_name,email,score')

            print('{},{},{},{},{}'.format(domain, first_name, last_name, email,
                                          score))
        else:
            print('Domain:\t{}'.format(domain))
            print('First Name:\t{}'.format(first_name))
            print('Last Name:\t{}'.format(last_name))
            print('Email:\t{}'.format(email))
            print('Score:\t{}'.format(score))
Ejemplo n.º 8
0
def search(client: EmailHunterClient, domain, offset, type_, print_header=True, is_file_output=False):
    if is_file_output:
        header = 'domain,email,type,sources'
        line_format = '{},{},{},{}'
    else:
        header = 'Domain\tEmail\tType\tSources'
        line_format = '{}\t{}\t{}\t{}'

    try:
        emails = client.search(domain, offset, type_)
    except Exception as e:
        print('Error during search request: {}'.format(e))
    else:
        for data in emails:
            email = data['value']
            type_ = data['type']
            sources = reduce_sources(data['sources'])

            if print_header:
                print(header)
                print_header = False

            print(line_format.format(domain, email, type_, sources))
Ejemplo n.º 9
0
from email_hunter import EmailHunterClient
import clearbit

email_hunter_client = EmailHunterClient('8552b3b2908a8f4bc745f7915cd8f393548c475d')
clearbit.key = 'my_key'


def email_exists(email):
    return email_hunter_client.exist(email)[0]


def get_user_additional_data(email):
    """Can't create valid api key...mocking data
    """
    # response = clearbit.Enrichment.find(email=email, stream=True)
    response = {
        'first_name': 'John',
        'last_name': 'Snow'
    }
    return response
Ejemplo n.º 10
0
def handle_cli(command,
               api_key,
               domain=None,
               offset=0,
               type=None,
               first_name=None,
               last_name=None,
               email=None,
               file=None):
    client = EmailHunterClient(api_key)
    reader = None

    if file is not None:
        file = open(file)
        reader = DictReader(file)

    if command == 'search':
        if file:
            handle_search_file(client, reader)
        elif domain:
            print('Searching {} for emails'.format(domain))

            if offset:
                print('Offset: {}'.format(offset))

            if type:
                print('Type: {}'.format(type))

            search(client, domain, offset, type)
        else:
            print('domain is required when using the generate command')
    elif command == 'generate':
        if file:
            handle_generate_file(client, reader)
        else:
            valid = True

            if not domain:
                print('domain is required when using the generate command')

            if not first_name:
                print('first_name is required when using the generate command')

            if not last_name:
                print('last_name is required when using the generate command')

            if valid:
                print('Finding email for {}, {}, {}'.format(
                    domain, first_name, last_name))
                generate(client, domain, first_name, last_name)
    elif command == 'exist':
        if file:
            handle_exist_file(client, reader)
        elif email:
            print('Checking if {} exists'.format(email))
            exist(client, email)
        else:
            print('email is required when using the exist command')
    else:
        print('Invalid command {}'.format(command))

    if file:
        file.close()
Ejemplo n.º 11
0
import os
from email_hunter import EmailHunterClient
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

email_hunter_client = EmailHunterClient(os.getenv('EMAILHUNTERS_KEY'))


def check_if_email_exists(email: str) -> bool:
    try:  # In case of emailhunter is down, don't validate if email exists in their db.
        return email_hunter_client.exist(email)[0]
    except:
        return True


def get_existing_email(domain: str) -> str:
    return get_existing_emails(domain)[0]['value']


def get_existing_emails(domain: str) -> list:
    return email_hunter_client.search(domain)
Ejemplo n.º 12
0
A more cleaner solution is possible, but it has been written very fast,
so certain things may seem confusing. A program with main function should be
implemented, but for now this seems to work
"""
import configparser
import random

from email_hunter import EmailHunterClient
from faker import Faker
from faker.providers import internet
import requests

config = configparser.ConfigParser()
config.read('config.ini')

email_hunter_client = EmailHunterClient(config['DEFAULT']['EmailHunterKey'])

fake = Faker()
fake.add_provider(internet)


def signup(email):
    user = {
        'username': fake.user_name(),
        'password': fake.password(),
    }

    response = requests.post(config['API']['BaseUrl'] + 'users/',
                             data={
                                 'username': user['username'],
                                 'password': user['password'],
Ejemplo n.º 13
0
from pip import logger

import clearbit
from email_hunter import EmailHunterClient

from .settings import EMAIL_HUNTER_KEY, CLEARBIT_KEY

# initializing 3rd party clients
clearbit.key = CLEARBIT_KEY
email_hunter_client = EmailHunterClient(EMAIL_HUNTER_KEY)


def get_user_extra_info(email):
    """
    This function should expand user's profile by info provided from clearbit.com
    Registration available only for US citizens.
    Getting sign up error "For security reasons, we need to confirm your phone number."
    """
    data = {}
    # response = clearbit.Enrichment.find(email=email, stream=True)

    # making stub intentionally
    response = {}

    if 'person' in response:
        data = {
            'first_name': response['person']['name']['givenName'],
            'last_name': response['person']['name']['familyName']
        }

    return data