mirror of https://github.com/rscmbbng/Border-Check
psy
11 years ago
4 changed files with 87 additions and 5 deletions
@ -1,12 +1,58 @@ |
|||||
|
#!/usr/local/bin/python |
||||
|
# -*- coding: iso-8859-15 -*- |
||||
|
""" |
||||
|
BC (Border-Check) is a tool to retrieve info of traceroute tests over website navigation routes. |
||||
|
GPLv3 - 2013 by psy (epsylon@riseup.net) |
||||
|
""" |
||||
|
from xml.dom.minidom import parseString |
||||
|
# extract data from a xml file |
||||
|
file = open('data.xml','r') |
||||
|
data = file.read() |
||||
|
file.close() |
||||
|
dom = parseString(data) |
||||
|
xmlTag = dom.getElementsByTagName('travel')[0].toxml() |
||||
|
xmlData= xmlTag.replace('<travel>','').replace('</travel>','') |
||||
|
xmlHost = dom.getElementsByTagName('host')[0].toxml() |
||||
|
xmlIP = dom.getElementsByTagName('ip')[0].toxml() |
||||
|
xmlRoutes = dom.getElementsByTagName('routes')[0].toxml() |
||||
|
xmlMeta = dom.getElementsByTagName('meta')[0].toxml() |
||||
|
|
||||
output = """ |
output = """ |
||||
<html> |
<html> |
||||
<head> |
<head> |
||||
<title>Border Check</title> |
<title>Border Check - Web Visualizator</title> |
||||
</head> |
</head> |
||||
<body> |
<body> |
||||
<div> |
<center> |
||||
<center><img src="images/WM1.svg"><center> |
<table> |
||||
</div> |
<tr> |
||||
|
<td><div><center><img src="images/WM1.svg"></center></div></td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td> |
||||
|
<center> |
||||
|
<table border="1"> |
||||
|
<tr> |
||||
|
<td><b>Host:</b></td> |
||||
|
<td>"""+xmlHost+"""</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td><b>IP:</b></td> |
||||
|
<td>"""+xmlIP+"""</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td><b>Packages Route:</b></td> |
||||
|
<td>"""+xmlRoutes+"""</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td><b>Metadata:</b></td> |
||||
|
<td>"""+xmlMeta+"""</td> |
||||
|
</tr> |
||||
|
</table> |
||||
|
</center> |
||||
|
</tr> |
||||
|
</table> |
||||
|
</center> |
||||
</body> |
</body> |
||||
</html> |
</html> |
||||
""" |
""" |
||||
|
@ -0,0 +1,31 @@ |
|||||
|
#!/usr/bin/python |
||||
|
# -*- coding: iso-8859-15 -*- |
||||
|
""" |
||||
|
BC (Border-Check) is a tool to retrieve info of traceroute tests over website navigation routes. |
||||
|
GPLv3 - 2013 by psy (epsylon@riseup.net) |
||||
|
""" |
||||
|
import xml.etree.ElementTree as ET |
||||
|
|
||||
|
class xml_reporting(object): |
||||
|
""" |
||||
|
Print results from a traceroute in an XML fashion |
||||
|
""" |
||||
|
def __init__(self, bc): |
||||
|
# initialize main BC |
||||
|
self.instance = bc |
||||
|
|
||||
|
def print_xml_results(self, filename): |
||||
|
root = ET.Element("travel") |
||||
|
host = ET.SubElement(root, "host") |
||||
|
ip = ET.SubElement(root, "ip") |
||||
|
routes = ET.SubElement(root, "routes") |
||||
|
meta = ET.SubElement(root, "meta") |
||||
|
|
||||
|
host.text = self.instance.url[0] |
||||
|
ip.text = self.instance.ip |
||||
|
routes.text = self.instance.routes |
||||
|
meta.text = "Connect here XML metadata" |
||||
|
|
||||
|
tree = ET.ElementTree(root) |
||||
|
tree.write(filename) |
||||
|
|
Loading…
Reference in new issue