Skip to content

Commit a8b59c6

Browse files
Merge pull request #103 from ChuckWoodraska/ID-1390
ID-1390 Utility functions to find all ips and emails.
2 parents 786873a + 2b05d75 commit a8b59c6

File tree

5 files changed

+192
-172
lines changed

5 files changed

+192
-172
lines changed

domaintools/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import datetime
22
import dateparser
3+
import re
34

45

56
def get_domain_age(create_date):
@@ -98,3 +99,15 @@ def prune_data(data_obj):
9899
if not isinstance(item, int) and not item:
99100
items_to_prune.append(index)
100101
data_obj[:] = [item for index, item in enumerate(data_obj) if index not in items_to_prune and len(item)]
102+
103+
104+
def find_emails(data_str):
105+
"""Find and returns all emails"""
106+
return set(re.findall(r'[\w\.-]+@[\w\.-]+', data_str))
107+
108+
109+
def find_ips(data_str):
110+
"""Find and returns all ipv4"""
111+
ipv4s = set(re.findall(r'\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b', data_str))
112+
return ipv4s
113+

0 commit comments

Comments
 (0)