def get_log_types():
url = "https://www.bro.org/sphinx/script-reference/"
resp = requests.get(url=url + "log-files.html")
soup = BeautifulSoup(resp.content, "html.parser")
bro_logs = dict(logs=[])
for table in soup.find_all("table", {"class": "docutils"}):
for row in table.find('tbody').find_all('tr'):
log = {}
cols = row.find_all('td')
cols = [ele.text.strip() for ele in cols]
tds = [ele for ele in cols if ele]
log['file'] = tds[0]
log['log_type'] = os.path.splitext(log['file'])[0]
log['description'] = tds[1]
log['fields'] = []
link = row.find('a', href=True)
# do not add a URL for notice_alarm.log
if link is not None and 'notice_alarm' not in log['log_type']:
log['url'] = urljoin(url, link['href'])
logger.info('adding log type: {}'.format(log['log_type']))
bro_logs['logs'].append(log)
return bro_logs
评论列表
文章目录