NAME

WWW::Extractor - Semi-automated extraction of records from WWW pages

SYNOPSIS

use strict;
use WWW::Extractor;

my($extractor) = WWW::Extractor->new();

$extractor->process($string);

DESCRIPTION

WWW::Extractor is a tool for semi automated extraction of records from a string containing HTML. One record within the string is marked up with extraction markups and the modules uses a pattern matching algorithm to match up the remaining records.

Extraction markup

The user markups up one record withing the HTML stream with the following symbols.

(((BEGIN)))

Begin a record

(((fieldname)))

Begin a field named fieldname

[[[literal string]]]

This identifies a block of text that the extractor attempts to match. This string is dumped out when the records are extracted.

{{{literal string}}}

This identifies a block of text that the extractor attempts to match. This string is not dumped out when the records are extracted.

(((nodump)))

This marks an area of text that is not to be dumped out.

(((/nodump)))

This ends a section of text that is not to be dumped out.

(((END)))

End a record.

ALGORITHM

The algorithm used is based on the edit distance wrapper generation method described in

@inproceedings{ chidlovskii00automatic, author = "Boris Chidlovskii and Jon Ragetli and Maarten de Rijke", title = "Automatic Wrapper Generation for Web Search Engines", booktitle = "Web-Age Information Management", pages = "399-410", year = "2000", url = "citeseer.nj.nec.com/chidlovskii00automatic.html" }

but with two major enhancements.

1 Before calculating edit distance, the system divides the tokens into different classification groups.
2 Instead of creating a general grammar from all of the records in a file, the data extractor creates one grammar from the sample entry and then matches the rest of the text to that one grammar.

METHODS

    $self->new()

    Standard constructor

    $self->open($string)

    Opens a string for processing.

    $self->read($hashref)

    Read the next processed entry into a hash pointer.

    $self->close()

    Closes off the string

    Captures a string that is outside of an entry and inserts it into an entry hash. The routine takes two arguments. One is the field that the entry hash is to be included in. The other is the regular expression which matches the field.

    $self->debug(i)

    Set the debug level. Higher numbers turn on more debug levels.

    If set to one then expand out the internal A tags and IMG tags to moving the href outside the tag.

    Set to the number of tags to match at the beginning of each entry. Default is 2.

    Number of tags to match at the end of an entry, The default is 1.

EXAMPLES

The distribution contains a sample driver application and test data in the examples directory. To look at the markup for the test data, search for the (((BEGIN))) tag.

To run a basic example

./examples/learn.wrapper < ./examples/sample1.html

To run an example with --expand-hrefs

./examples/learn.wrapper --expand-hrefs < ./examples/sample1.html

DISCUSSION AND DEVELOPMENT

A wiki on this module is located at

http://www.gnacademy.org/twiki/bin/view/Gna/AutomatedDataExtraction

Please contact gna@gnacademy.org for ideas on improvements.

COPYRIGHT AND LICENSE

Copyright 2002, 2003 Globewide Network Academy

Redistributed under the terms of the Lesser GNU Public License

5 POD Errors

The following errors were encountered while parsing the POD:

Around line 95:

You can't have =items (as at line 107) unless the first thing after the =over is an =item

Around line 205:

=pod directives shouldn't be over one line long! Ignoring all 2 lines of content

Around line 238:

=pod directives shouldn't be over one line long! Ignoring all 2 lines of content

Around line 254:

=pod directives shouldn't be over one line long! Ignoring all 2 lines of content

Around line 271:

=pod directives shouldn't be over one line long! Ignoring all 2 lines of content