weatherget/weatherbug.sh
2020-07-21 10:41:16 -06:00

22 lines
693 B
Bash
Executable File

#! /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
my $URL_lat = 40.48967;
my $URL_lng = -111.93882;
my $URL_ProID = 23;
my $URL_StatID = "C3430";
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";
my $json = decode_json $info or die "Error";
my $loc = %{$json}{"Station"}->{"StationId"};
my $temp = %{$json}{"Observation"}->{"Temperature"};
my $windS = %{$json}{"Observation"}->{"WindSpeedAvg"};
my $windD = %{$json}{"Observation"}->{"WindDirectionAvg"};
print "?:".$temp.":".$windS.":".$windD.":".$loc;