#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
"""
BC (Border-Check) is a tool to retrieve info of traceroute tests over website navigation routes.
GPLv3 - 2013-2014-2015 by psy (epsylon@riseup.net)
"""
from xml.dom.minidom import parseString
import xml.etree.ElementTree as ET
import re
#function to split ISP company names from ASN
def ASN_Split(asn):
name_parts = []
for i in asn.split():
if re.match(r'AS\d{1,6}$', i):
asn = i
elif not re.match(r'AS\d{1,6}$', i):
name_parts.append(i)
company = ' '.join(name_parts)
return (asn, company)
got_data = False
msg=""
url=""
try:
# extract data from a xml file
f = open('data.xml', 'r')
f2 = open('data.xml', 'r')
xml = ET.parse(f)
data = f2.read()
dom = parseString(data.encode('utf-8'))
f.close()
f2.close()
n_hops = dom.getElementsByTagName('hop')[-1].toxml().replace('