diff options
-rwxr-xr-x | har2kml | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#!/bin/sh +# +# Use geotraceroute to fetch traceroutes to all hosts used to view a web page and print KML +# output for all traces. + +if [ "$1" ]; then + har="$1" +else + har=har-data/https\:%%www.politi.no.har +fi + +har2hosts() { + jq -r '.log | .entries | map(.request) | map(.url) | join("\n")' < $har | + cut -d/ -f3 | sort -u +} + +for h in $(har2hosts) ; do + kml="$h.kml" + curl -s "https://www.geotraceroute.com/petter.php?host=$h" > "$kml" + kmls="$kmls $kml" +done + +cat $kmls | perl -e '$line = ""; while (<>) { $line .= $_; }; $line =~ s%</Document>\s</kml>\s<\?xml version="1.0" encoding="UTF-8"\?>\s<kml xmlns="http://www.opengis.net/kml/2.2">\s<Document>\s<Info>Generated by https://geotraceroute.com</Info>%%gs; $line =~ s%<name>.+</name>%%g; print $line;' |