Image 01
profile-image

angelrod

Angel Rodriguez
Karamba Weather.COM

Karamba & Superkaramba by iZelpII 55 comments

You were right!!! I ran it from shell and it worked....Thank you ;) - Jul 01 2003
Karamba Weather.COM

Karamba & Superkaramba by iZelpII 55 comments

If I run the script from console, it gives me all the info for my city. But when I run it form superkaramba I only see the background. I already pressed like 20 times the "update" option and nothing.

My script climaEn.pl :

#!/usr/bin/perl
#usage: perl /usr/share/karamba-0.17/themes/karamba_weather/script/clima.pl www.weather.com/weather/local/BLXX0006
use LWP::UserAgent;
use HTML::TokeParser;

#City code according to http://www.weather.com, please check the small README
$cityCode = "MXGO0035";
$url = "www.w3.weather.com/outlook/travel/local/" . $cityCode ."?&setcookie=1";
#my $url = @ARGV[0];
my $ua = new LWP::UserAgent;

$url = "http://$url" unless($url =~ /^http:\/\//);

if($ENV{'http_proxy'}){
$ua->env_proxy;
$ua->proxy(http => $ENV{'http_proxy'});
}

my $req = new HTTP::Request 'GET',"$url";
# uncomment if you need it
# $req->quthorization_basic("user","pass");
my $res = $ua->request($req);
$res->is_success or die("didn't work $!");

my $page = $res->as_string;
$page =~ s/\&deg\;//g;
$page =~ s/\&nbsp\;/ /g;
$page =~ s/Feels Like/Feels Like /g;
my $p = HTML::TokeParser->new(\$page);

$initPositionIcon = index ($page, "http://image.weather.com/web/common/wxicons/52/");
$endPositionIcon = index ($page," ", $initPositionIcon);
$nameIconFile = substr($page, $initPositionIcon + 47, $endPositionIcon -47 - $initPositionIcon);

while ( $token = $p->get_tag("td") ) {
my $text = $p->get_trimmed_text("/td");
if ($token->[1]{class}=~/obsInfo1/i) {
$report = $report . "$text\n";
}
if ($token->[1]{class}=~/obsInfo2/i) {
$report = $report . "$text\n";
}
if ($token->[1]{class}=~/obsReported/i) {
$reportHeader = "$text\n";
}

}

$endPositionCity = index ($reportHeader, "Last");
$textCity = substr ($reportHeader, 15, $endPositionCity -15);
$textUpdateTime = substr ($reportHeader, $endPositionCity, -1);
print $textCity . "\n";
print "pics/" . $nameIconFile . "\n";
print $report;
print $textUpdateTime . "\n";



Any hints? - Jun 30 2003
Karamba Weather.COM

Karamba & Superkaramba by iZelpII 55 comments

If I run the script from console, it gives me all the info for my city. But when I run it form superkaramba I only see the background. I already pressed like 20 times the "update" option and nothing.

Any hints? - Jun 30 2003
Karamba Weather.COM

Karamba & Superkaramba by iZelpII 55 comments

If I run the script from console, it gives me all the info for my city. But when I run it form superkaramba I only see the background. I already pressed like 20 times the "update" option and nothing.

Any hints? - Jun 30 2003