23 lines
597 B
Python
23 lines
597 B
Python
|
import csv
|
||
|
from io import StringIO
|
||
|
from validators import ipv4, ipv6, url, domain
|
||
|
|
||
|
|
||
|
def extract(uploaded):
|
||
|
hosts = []
|
||
|
content = uploaded.read()
|
||
|
decoded = content.decode("utf-8")
|
||
|
file = StringIO(decoded)
|
||
|
csv_data = csv.reader(file, delimiter=",")
|
||
|
for row in csv_data:
|
||
|
for value in row:
|
||
|
if url(value):
|
||
|
hosts.append(value)
|
||
|
elif domain(value):
|
||
|
hosts.append(value)
|
||
|
elif ipv4(value):
|
||
|
hosts.append(value)
|
||
|
elif ipv6(value):
|
||
|
hosts.append(value)
|
||
|
return hosts
|