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

Annotation of openbsd/errata_scraper/errata_scraper.pl, Revision 1.4

1.1       andrew      1: #!/usr/bin/perl
1.4     ! andrew      2: # $AFresh1: errata_scraper.pl,v 1.3 2011/03/23 18:46:16 andrew Exp $
1.1       andrew      3: ########################################################################
                      4: # Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com>
                      5: #
                      6: # Permission to use, copy, modify, and distribute this software for any
                      7: # purpose with or without fee is hereby granted, provided that the above
                      8: # copyright notice and this permission notice appear in all copies.
                      9: #
                     10: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17: ########################################################################
                     18: use strict;
                     19: use warnings;
                     20:
1.2       andrew     21: use Mojo::UserAgent;
                     22:
1.3       andrew     23: my $base_uri = 'http://www.openbsd.org/';
1.2       andrew     24:
1.3       andrew     25: my $ua = Mojo::UserAgent->new;
                     26:
                     27: my $ls = $ua->get( $base_uri . 'errata.html' )->res->dom('a[href^="errata"]');
                     28:
                     29: foreach my $l ( @{$ls}[ -2, -1 ] ) {
                     30:     print 'Errata for OpenBSD ', $l->text, "\n";
                     31:     foreach my $e (
                     32:         reverse @{ $ua->get( $base_uri . $l->attrs->{'href'} )->res->dom('li')
                     33:         } )
                     34:     {
1.4     ! andrew     35:         my $patch = $e->at('a[href$=".patch"]')->replace('')->{href};
        !            36:         my $title = $e->at('strong')->replace('')->all_text;
        !            37:         my $arch  = $e->at('i')->replace('')->all_text;
        !            38:         my $descr = $e->all_text;
1.2       andrew     39:         $descr =~ s/\s+/ /gs;
1.4     ! andrew     40:         $descr =~ s/\s(\.(?:\s|$))/$1/gs;
        !            41:         $descr =~ s/\.+$/./gs;
1.2       andrew     42:
                     43:         print 'Title: ', $title, "\n";
                     44:         print 'Arch:  ', $arch,  "\n";
                     45:         print 'Patch: ', $patch, "\n";
                     46:         print 'Descr: ', $descr, "\n";
                     47:         print "\n";
1.1       andrew     48:     }
1.3       andrew     49: }

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