Im from Spain, and for this to work, i had to modify the perl script to use City Codes instead of Zip Codes. That´s because it seems there are no Zip Codes for spanish City´s.
I debugged my problem searching my city for the the "Zip Code" using the api (example: http://api.wxbug.net/getLocationsXML.as ... ing=copper) and i realized that my City has no "Zip Code" (it whas blank). But it showed a "City Code" instead, so there whas a chance to make a fix. BUT, another funny problem whas, that at first, using the Zip Code for my City that shows this "maintained" (11 Mar 2011) list (http://www.rap.ucar.edu/weather/surface/stations.txt) (which is totally erroneous with the weatherbug stations) posted in the old weatherbug threads, and using the original script, i whas graphing results from some Airport of USA, lol. Finally i have fixed all issues.
So, once i get my City Code, i made a test with the api asking for my City Code (example: http://api.wxbug.net/getLiveWeatherRSS. ... unittype=1) and it worked, i whas getting my City weather. Then i modified the regex of the script to match the new values of the xml.
Later i changed the graphs to use Celtius instead of Fharenheit, creating a new CDEF function "F to Celtius" (cdef=CURRENT_DATA_SOURCE,32,-,0.55555555556,*), (Also modified the graph template and changed "ºF" to "C" (because of XML parse error and also the Fharenheit to Celtius conversion)), and that´s it.
The script looks like this:
Code: Select all
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
#my $httpaddr = "http://api.wxbug.net/getLiveWeatherRSS.aspx?ACode=$ARGV[0]&zipcode=$ARGV[1]&unittype=0";
my $httpaddr = "http://api.wxbug.net/getLiveWeatherRSS.aspx?ACode=$ARGV[0]&citycode=$ARGV[1]&unittype=1";
my %data;
$_ = LWP::Simple::get($httpaddr);
# regex in html source order
if ($_ =~ /<aws:dew-point units="°C">(\d+?)<\/aws:dew-point>/g) { $data{DewPoint} = $1; }
if ($_ =~ /<aws:feels-like units="°C">(\d+?)<\/aws:feels-like>/g) { $data{FeelsLike} = $1; }
if ($_ =~ /<aws:humidity units="%">(\d+?)<\/aws:humidity>/g) { $data{Humidity} = $1; }
if ($_ =~ /<aws:pressure units="mb">(\d+?\.\d+?)<\/aws:pressure>/g) { $data{Pressure} = $1; }
if ($_ =~ /<aws:rain-today units="mm">(\d+?\.\d+?)<\/aws:rain-today>/g) { $data{Rain} = $1; }
if ($_ =~ /<aws:temp units="°C">(\d+?\.\d+?)<\/aws:temp>/g) { $data{Temp} = $1; }
if ($_ =~ /<aws:wind-speed units="km\/h">(\d+?)<\/aws:wind-speed>/g) { $data{Wind} = $1; }
for (keys %data) {
printf "%s:%s ", $_, $data{$_};
}
print "\n";