[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.1

1.1     ! andrew      1: #!/usr/bin/perl
        !             2: # $AFresh1$
        !             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:
        !            21: use Mojo::Client;
        !            22: my $client = Mojo::Client->new;
        !            23:
        !            24: $client->get(
        !            25:     'http://www.openbsd.org/errata48.html' => sub {
        !            26:         shift->res->dom('li')->each(
        !            27:             sub {
        !            28:                 my $e = shift;
        !            29:
        !            30:                 my $patch = $e->at('a[href$=".patch"]')->attrs->{href};
        !            31:
        !            32:                 my $title = $e->at('strong')->replace('')->all_text;
        !            33:                 $title =~ s/\s+/ /gxms;
        !            34:
        !            35:                 my $arch = $e->at('i')->replace('')->all_text;
        !            36:                 $arch =~ s/\s+/ /gxms;
        !            37:
        !            38:                 # the li ends at p, but the parser expects a /li
        !            39:                 $e->at('p')->replace('');
        !            40:
        !            41:                 my $descr = $e->all_text;
        !            42:                 $descr =~ s/\s+/ /gxms;
        !            43:                 $descr =~ s/^\s+|\s+$//gxms;
        !            44:
        !            45:                 print 'Title: ', $title, "\n";
        !            46:                 print 'Arch: ',  $arch,  "\n";
        !            47:                 print 'Patch: ', $patch, "\n";
        !            48:                 print 'Descr: ', $descr, "\n";
        !            49:                 print "\n";
        !            50:             }
        !            51:         );
        !            52:     }
        !            53: );
        !            54:
        !            55: $client->start;

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