=================================================================== RCS file: /cvs/openbsd/errata_scraper/errata_scraper.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- openbsd/errata_scraper/errata_scraper.pl 2011/03/21 17:26:58 1.1 +++ openbsd/errata_scraper/errata_scraper.pl 2011/03/21 17:28:15 1.2 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $AFresh1$ +# $AFresh1: errata_scraper.pl,v 1.1 2011/03/21 16:26:58 andrew Exp $ ######################################################################## # Copyright (c) 2011 Andrew Fresh # @@ -18,38 +18,24 @@ use strict; use warnings; -use Mojo::Client; -my $client = Mojo::Client->new; - -$client->get( - 'http://www.openbsd.org/errata48.html' => sub { - shift->res->dom('li')->each( - sub { - my $e = shift; - - my $patch = $e->at('a[href$=".patch"]')->attrs->{href}; - - my $title = $e->at('strong')->replace('')->all_text; - $title =~ s/\s+/ /gxms; - - my $arch = $e->at('i')->replace('')->all_text; - $arch =~ s/\s+/ /gxms; - - # the li ends at p, but the parser expects a /li - $e->at('p')->replace(''); - - my $descr = $e->all_text; - $descr =~ s/\s+/ /gxms; - $descr =~ s/^\s+|\s+$//gxms; - - print 'Title: ', $title, "\n"; - print 'Arch: ', $arch, "\n"; - print 'Patch: ', $patch, "\n"; - print 'Descr: ', $descr, "\n"; - print "\n"; - } - ); +use Mojo::UserAgent; +use Mojo::ByteStream 'b'; + +Mojo::UserAgent->new->get('http://www.openbsd.org/errata48.html') + ->res->dom('li')->each( + sub { + my $e = shift; + + my $patch = $e->at('a[href$=".patch"]')->attrs->{href}; + my $title = b( $e->at('strong')->replace('')->all_text )->trim; + my $arch = b( $e->at('i')->replace('')->all_text )->trim; + my $descr = b( $e->all_text )->trim; + $descr =~ s/\s+/ /gs; + + print 'Title: ', $title, "\n"; + print 'Arch: ', $arch, "\n"; + print 'Patch: ', $patch, "\n"; + print 'Descr: ', $descr, "\n"; + print "\n"; } ); - -$client->start;