I think the redesign is actually making it easier to parse.  I realized
I had a Perl sandbox available with my Linux server, so I was hacking
away a bit.  HTML::TreeBuilder is neat.  One assumption I am making is
that the format is pretty static - I'm sure that's a bad assumption, but
I don't have any choice at the moment.  Anyway, I was able to get the
Precipitation chance out, so the rest shouldn't be too horrible.  More
tomorrow.


Code:
--------------------
    
  use strict;
  
  use HTML::TreeBuilder;
  use Time::Local;
  use HTML::Entities qw(decode_entities);
  
  my %wetData;
  
  local $/ = undef;
  open FILE, "myfile" or die "Couldn't open file: $!";
  binmode FILE;
  my $content = <FILE>;
  close FILE;
  
  print "Parsing tree\n";
  my $tree = HTML::TreeBuilder->new; # empty tree
  $tree->parse($content);
  $tree->eof();
  # print $tree->as_HTML;
  
  my $outcome = ($tree->look_down( "_tag", "div", "class", "wx-data-part"))[7];
                print $outcome->as_text;
                print $outcome->as_HTML;
                
                my $res = ($outcome->look_down( "_tag", "div", "class", 
"wx-data"))[0];
                print $res->as_text;
                print $res->as_HTML;
  
  if ($outcome) {
  if ($res->as_text =~ m/(.*%)/) {
                                        print "Outcome\n";
                                        print $1;
                                        print "\n";
  $wetData{-1}{'forecastPrec'} = $1;
  $wetData{0}{'forecastPrec'} = $1;
  }
                }
  
--------------------


I get 60%, and that's a passing grade in my book.  :-)


------------------------------------------------------------------------
plympton's Profile: http://forums.slimdevices.com/member.php?userid=12955
View this thread: http://forums.slimdevices.com/showthread.php?t=14327

_______________________________________________
plugins mailing list
plugins@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to