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

use strict; use WWW::Extractor; my($extractor) = WWW::Extractor->new(); $extractor->process($string);

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.
The user markups up one record withing the HTML stream with the following symbols.
Begin a record
Begin a field named fieldname
This identifies a block of text that the extractor attempts to match. This string is dumped out when the records are extracted.
This identifies a block of text that the extractor attempts to match. This string is not dumped out when the records are extracted.
This marks an area of text that is not to be dumped out.
This ends a section of text that is not to be dumped out.
End a record.

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.

$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.

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

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 2002, 2003 Globewide Network Academy
Redistributed under the terms of the Lesser GNU Public License