Annotation of openbsd/errata_scraper/errata_scraper.pl, Revision 1.2
1.1 andrew 1: #!/usr/bin/perl
1.2 ! andrew 2: # $AFresh1: errata_scraper.pl,v 1.1 2011/03/21 16:26:58 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:
! 24: Mojo::UserAgent->new->get('http://www.openbsd.org/errata48.html')
! 25: ->res->dom('li')->each(
! 26: sub {
! 27: my $e = shift;
! 28:
! 29: my $patch = $e->at('a[href$=".patch"]')->attrs->{href};
! 30: my $title = b( $e->at('strong')->replace('')->all_text )->trim;
! 31: my $arch = b( $e->at('i')->replace('')->all_text )->trim;
! 32: my $descr = b( $e->all_text )->trim;
! 33: $descr =~ s/\s+/ /gs;
! 34:
! 35: print 'Title: ', $title, "\n";
! 36: print 'Arch: ', $arch, "\n";
! 37: print 'Patch: ', $patch, "\n";
! 38: print 'Descr: ', $descr, "\n";
! 39: print "\n";
1.1 andrew 40: }
41: );
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>