Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Feb 2, 2016
0 parents commit c645761
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions get_ms_data
@@ -0,0 +1,36 @@
#!/usr/bin/perl

use strict;
use warnings;
use 5.010;

use LWP::UserAgent;

my @urls = qw[
https://postmaster.live.com/snds/data.aspx
https://postmaster.live.com/snds/ipStatus.aspx
];
my $key = shift || $ENV{SNDS_KEY};

die "No SNDS key given\n" unless defined $key;

my $ua = LWP::UserAgent->new;

foreach (@urls) {
get_url($ua, $_, $key);
}

sub get_url {
my ($ua, $url, $key) = @_;

my $resp = $ua->get("$url?key=$key");
my $data = $resp->content;
unless (length $data) {
warn "No data for $url\n";
return;
}

my $file = $resp->filename;
open my $out_fh, '>', $file or die "$file: $!";
print $out_fh $data;
}

0 comments on commit c645761

Please sign in to comment.