#!/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%\s\s<\?xml version="1.0" encoding="UTF-8"\?>\s\s\sGenerated by https://geotraceroute.com%%gs; $line =~ s%.+%%g; print $line;'