-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hunter.py
32 lines (26 loc) · 1.2 KB
/
Hunter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
from pyhunter import PyHunter
from datetime import datetime
def hunter_mail(api, company, number):
date = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
try:
hunter = PyHunter(api)
result = hunter.domain_search(company=company, limit=10)
with open('correos.txt','a') as f:
f.write(date)
f.write('\n')
counter = 0
for i in range(int(number)):
if (result['emails'][i]['first_name'] is not None):
info = ('[+] '+result['emails'][i]['first_name']+' '+result['emails'][i]['last_name']+': '+result['emails'][i]['value'])
counter += 1
f.write('%s\n' %info)
with open('logs.info', 'a') as j:
j.write(f'[{date} HUNTER]: Se ha recuperado un correo\n')
with open('logs.info', 'a') as j:
j.write(f'[{date} HUNTER]: Se guardaron ' + str(counter) + ' correos.\n')
print('\nSe guardaron ',counter,' correos.')
except Exception as e:
with open('logs.info', 'a') as j:
j.write(f'[{date} HUNTER ERROR]: {e}\n')
print('Error:', e)