Annotation of openbsd/errata_scraper/errata_scraper.pl, Revision 1.3
1.1 andrew 1: #!/usr/bin/perl
1.3 ! andrew 2: # $AFresh1: errata_scraper.pl,v 1.2 2011/03/21 16:28:15 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: use Mojo::ByteStream 'b';
23:
1.3 ! andrew 24: my $base_uri = 'http://www.openbsd.org/';
1.2 andrew 25:
1.3 ! andrew 26: my $ua = Mojo::UserAgent->new;
! 27:
! 28: my $ls = $ua->get( $base_uri . 'errata.html' )->res->dom('a[href^="errata"]');
! 29:
! 30: foreach my $l ( @{$ls}[ -2, -1 ] ) {
! 31: print 'Errata for OpenBSD ', $l->text, "\n";
! 32: foreach my $e (
! 33: reverse @{ $ua->get( $base_uri . $l->attrs->{'href'} )->res->dom('li')
! 34: } )
! 35: {
1.2 andrew 36: my $patch = $e->at('a[href$=".patch"]')->attrs->{href};
37: my $title = b( $e->at('strong')->replace('')->all_text )->trim;
38: my $arch = b( $e->at('i')->replace('')->all_text )->trim;
39: my $descr = b( $e->all_text )->trim;
40: $descr =~ s/\s+/ /gs;
41:
42: print 'Title: ', $title, "\n";
43: print 'Arch: ', $arch, "\n";
44: print 'Patch: ', $patch, "\n";
45: print 'Descr: ', $descr, "\n";
46: print "\n";
1.1 andrew 47: }
1.3 ! andrew 48: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>