Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions modules/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .utils import multi_thread
from .color import color


def get_emails(node):
"""Finds all emails associated with node

Expand Down Expand Up @@ -61,6 +62,17 @@ def get_images(node):
return links


def get_metadata(node):
"""Collect response headers.

Args:
node (LinkNode): node used to get metadata from
Returns:
metadata (dict): dictionary with metadata
"""
return node.response.headers


class LinkNode:
"""Represents link node in a link tree

Expand All @@ -77,6 +89,7 @@ def __init__(self, link):
self._emails = []
self._links = []
self._images = []
self._metadata = {}

# Attempts to connect to link, throws an error if link is unreachable
try:
Expand Down Expand Up @@ -132,6 +145,15 @@ def children(self):
self._children = self._node.find_all('a')
return self._children

@property
def metadata(self):
"""
Getter for node metadata
"""
if not self._metadata:
self._metadata = get_metadata(self)
return self._metadata

@staticmethod
def valid_email(email):
"""Static method used to validate emails"""
Expand Down