diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2017-01-14 15:59:21 +0100 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2017-01-14 15:59:54 +0100 |
commit | 9dc375b618f5a10f31ffa3e1ea182ac51e92c86d (patch) | |
tree | b5e2cd675eeb5cd1e0264e73d33b9a2b054d7948 /har2kml | |
parent | c536288ee01940b8ef46d724ce76f1ad7ec3e6c2 (diff) |
Add draft script har2kml to create KML data showing where the web trafic is flowing.
Diffstat (limited to 'har2kml')
-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;' |