2020-01-21 14:01:04 -07:00
#! /usr/bin/perl -w
use strict;
use warnings;
use JSON;
#Have to open the web page and look in developer mode to get this info
2023-02-10 10:54:10 -07:00
my $URL_lat = $ARGV [ 0] or scalar( 40.48967) ;
my $URL_lng = $ARGV [ 1] or scalar( -111.93882) ;
my $URL_ProID = $ARGV [ 2] or scalar( 23) ;
my $URL_StatID = $ARGV [ 3] or scalar( "C3430" ) ;
2020-01-21 14:01:04 -07:00
2020-07-21 10:41:16 -06:00
my $info = ` curl -sm 5 " https://www.weatherbug.com/api/observation?lat= $URL_lat &lng= $URL_lng &providerId= $URL_ProID &stationId= $URL_StatID " ` or die "Error" ;
2020-01-21 14:01:04 -07:00
my $json = decode_json $info or die "Error" ;
2020-07-21 10:41:16 -06:00
my $loc = %{ $json } { "Station" } ->{ "StationId" } ;
my $temp = %{ $json } { "Observation" } ->{ "Temperature" } ;
2020-01-21 14:01:04 -07:00
my $windS = %{ $json } { "Observation" } ->{ "WindSpeedAvg" } ;
my $windD = %{ $json } { "Observation" } ->{ "WindDirectionAvg" } ;
2020-07-21 10:41:16 -06:00
print "?:" .$temp .":" .$windS .":" .$windD .":" .$loc ;