diff --git a/web/index.py b/web/index.py index 408c085..132c106 100755 --- a/web/index.py +++ b/web/index.py @@ -6,6 +6,18 @@ GPLv3 - 2013 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) # extract data from a xml file f = open('data.xml', 'r') @@ -23,9 +35,11 @@ latlong= [] asn_list =[] server_name_list = [] timestamp_list = [] +telco_list = [] last_hop = int(xml.findall('hop')[-1].text) country_code_list = [] + for counter in range(0, last_hop+1): url = xml.getroot().text hop_element = parseString(dom.getElementsByTagName('hop')[counter].toxml().encode('utf-8')) @@ -40,7 +54,8 @@ for counter in range(0, last_hop+1): latlong = [float(latitude.encode('utf-8')), float(longitude.encode('utf-8'))] geoarray.append(latlong) - asn_list.append(asn.encode('utf-8')) + asn_list.append(ASN_Split(asn.encode('utf-8'))[0]) + telco_list.append(ASN_Split(asn.encode('utf-8'))[1]) hop = int(hop) +1 hop_list.append(str(hop)) hop_ip_list.append(hop_ip.encode('utf-8')) @@ -102,12 +117,6 @@ output = """
------------------------------
-Border Check is a project by Roel Roscam Abbing. Programming by Lord Epsylon. Design by Bart Van Haren.
-BC was developed during Summer Sessions 2013 with with the support of V2_ Institute For The Unstable Media at Laboral Centro De Arte and the MP19 Openlab. - It uses Python, OpenStreetMap, Leaflet and others.
------------------------------