theHarvester/cymonparser.py

19 lines
539 B
Python
Raw Normal View History

2018-12-10 01:45:36 +08:00
from bs4 import BeautifulSoup
import re
class parser:
def __init__(self, results):
self.results = results
self.ipaddresses = []
2018-12-23 04:29:11 +08:00
self.soup = BeautifulSoup(results.results, features="html.parser")
2018-12-10 01:45:36 +08:00
def search_ipaddresses(self):
try:
tags = self.soup.findAll('td')
2018-12-23 04:29:11 +08:00
allip = re.findall(r'[0-9]+(?:\.[0-9]+){3}',str(tags))
2018-12-10 01:45:36 +08:00
self.ipaddresses = set(allip)
return self.ipaddresses
except Exception as e:
print("Error occurred: " + str(e))