weatherget/weatherbug.sh
2020-01-21 15:10:25 -07:00

21 lines
639 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 $temp = %{$json}{"Observation"}->{"Temperature"};
my $windS = %{$json}{"Observation"}->{"WindSpeedAvg"};
my $windD = %{$json}{"Observation"}->{"WindDirectionAvg"};
print "Unknown:".$temp.":".$windS.":".$windD;