./get_meteo.pl 0000754 0001751 0001001 00000003062 12116163461 012756 0 ustar gianluca None #!/usr/bin/perl
#
#=BEGIN BRAINWORKS GPL
#
# This file is part of the BrainWorks RPi Environmental Monitor.
#
# Copyright(c) 2013 Gianluca Filippini
# http://www.brainworks.it
# info@brainworks.it
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
#=END BRAINWORKS GPL
#
use strict;
use warnings;
use HTML::TableExtract;
use LWP::Simple;
my $file = 'meteo.html';
my $rc = `wget -q http://www.ilmeteo.it/meteo/Cremona -O page.html`;
open (RESULT, '>', $file);
open (FILE, 'page.html');
while () {
# chomp;
$_ =~ s/ //g;
$_ =~ s/°/ /g;
$_ =~ s/à/ /g;
print RESULT $_;
}
close (FILE);
close (RESULT);
my @headers = qw( Ora Tempo T );
my $te = HTML::TableExtract->new(
headers => \@headers,
attribs => { class => 'datatable' },
);
$te->parse_file($file);
my ($table) = $te->tables;
for my $row ($te->rows ) {
my $line=join(",", @$row);
if(($line=~/^\d\d/)&&(!($line=~/^00/)))
{
print $line."\n";
}
}
#EOF