[BACK]Return to errata_scraper.pl CVS log [TXT][DIR] Up to [local] / openbsd / errata_scraper

Diff for /openbsd/errata_scraper/errata_scraper.pl between version 1.1 and 1.3

version 1.1, 2011/03/21 17:26:58 version 1.3, 2011/03/23 19:46:16
Line 1 
Line 1 
 #!/usr/bin/perl  #!/usr/bin/perl
 # $AFresh1$  # $AFresh1: errata_scraper.pl,v 1.2 2011/03/21 16:28:15 andrew Exp $
 ########################################################################  ########################################################################
 # Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com>  # Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com>
 #  #
Line 18 
Line 18 
 use strict;  use strict;
 use warnings;  use warnings;
   
 use Mojo::Client;  use Mojo::UserAgent;
 my $client = Mojo::Client->new;  use Mojo::ByteStream 'b';
   
 $client->get(  my $base_uri = 'http://www.openbsd.org/';
     'http://www.openbsd.org/errata48.html' => sub {  
         shift->res->dom('li')->each(  my $ua = Mojo::UserAgent->new;
             sub {  
                 my $e = shift;  my $ls = $ua->get( $base_uri . 'errata.html' )->res->dom('a[href^="errata"]');
   
                 my $patch = $e->at('a[href$=".patch"]')->attrs->{href};  foreach my $l ( @{$ls}[ -2, -1 ] ) {
       print 'Errata for OpenBSD ', $l->text, "\n";
                 my $title = $e->at('strong')->replace('')->all_text;      foreach my $e (
                 $title =~ s/\s+/ /gxms;          reverse @{ $ua->get( $base_uri . $l->attrs->{'href'} )->res->dom('li')
           } )
                 my $arch = $e->at('i')->replace('')->all_text;      {
                 $arch =~ s/\s+/ /gxms;          my $patch = $e->at('a[href$=".patch"]')->attrs->{href};
           my $title = b( $e->at('strong')->replace('')->all_text )->trim;
                 # the li ends at p, but the parser expects a /li          my $arch  = b( $e->at('i')->replace('')->all_text )->trim;
                 $e->at('p')->replace('');          my $descr = b( $e->all_text )->trim;
           $descr =~ s/\s+/ /gs;
                 my $descr = $e->all_text;  
                 $descr =~ s/\s+/ /gxms;          print 'Title: ', $title, "\n";
                 $descr =~ s/^\s+|\s+$//gxms;          print 'Arch:  ', $arch,  "\n";
           print 'Patch: ', $patch, "\n";
                 print 'Title: ', $title, "\n";          print 'Descr: ', $descr, "\n";
                 print 'Arch: ',  $arch,  "\n";          print "\n";
                 print 'Patch: ', $patch, "\n";  
                 print 'Descr: ', $descr, "\n";  
                 print "\n";  
             }  
         );  
     }      }
 );  }
   
 $client->start;  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>