Last active
June 26, 2018 10:58
-
-
Save robhammond/8800607 to your computer and use it in GitHub Desktop.
Get date and chart x-axis values from the JSON created when generating a SEO visibility chart in SearchMetrics. Makes it easier to plot YoY growth etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use Modern::Perl; | |
use Mojo::JSON qw(decode_json); | |
# seo-paid-visibility | |
my $raw = <<EOF; | |
{"data":{...}} | |
EOF | |
$raw =~ s!,\s?\"wrapper\"\:.*?$!}!s; | |
my $data = decode_json($raw); | |
my @dates; | |
for my $d (@{$data->{'data'}->{'chart'}->{'xAxis'}->{'categories'}}) { | |
push @dates, $d; | |
} | |
my $i = 0; | |
say $data->{'data'}->{'chart'}->{'series'}->[0]->{'name'}; | |
for my $d (@{$data->{'data'}->{'chart'}->{'series'}->[0]->{'data'}}) { | |
# next unless $d->{'y'}; | |
my $date = $dates[$i]; | |
$date =~ s!^(..)/(..)/(....)$!$3-$1-$2!; | |
say $date . "\t" . $d->{'y'}; | |
$i++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment