Annotation of openbsd/errata_scraper/errata_scraper.pl, Revision 1.5
1.1 andrew 1: #!/usr/bin/perl
1.5 ! andrew 2: # $AFresh1: errata_scraper.pl,v 1.4 2011/05/29 01:04:30 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 (
1.5 ! andrew 32: reverse @{ $ua->get( $base_uri . $l->attr('href') )->res->dom('li')
1.3 andrew 33: } )
34: {
1.5 ! andrew 35: my $title;
! 36: if (my $t = $e->at('strong')) {
! 37: $title = $t->all_text;
! 38: $t->replace('');
! 39: }
! 40: else {
! 41: next;
! 42: }
! 43: my $patch;
! 44: if (my $p = $e->at('a[href$=".patch.sig"],a[href$=".patch"]')) {
! 45: $patch = $p->attr('href');
! 46: $p->replace('');
! 47: }
! 48: my $arch = $e->at('i')->tap(sub { $_[0]->replace('') } )->text;
1.4 andrew 49: my $descr = $e->all_text;
1.2 andrew 50: $descr =~ s/\s+/ /gs;
1.4 andrew 51: $descr =~ s/\s(\.(?:\s|$))/$1/gs;
52: $descr =~ s/\.+$/./gs;
1.2 andrew 53:
54: print 'Title: ', $title, "\n";
55: print 'Arch: ', $arch, "\n";
1.5 ! andrew 56: print 'Patch: ', $patch, "\n" if $patch;
1.2 andrew 57: print 'Descr: ', $descr, "\n";
58: print "\n";
1.1 andrew 59: }
1.3 andrew 60: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>