man HTML::Munger () - Module which simplifies the creation of web filters.
NAME
HTML::Munger - Module which simplifies the creation of web filters.
SYNOPSIS
use HTML::Munger;
$munger = new HTML::Munger; $munger->set_munger(\&filter_function); $output = $munger->munge($URL, $selfURL, $input);
DESCRIPTION
HTML::Munger is a simple module which allows easy creation of web page filtering software. It was first written to build the pootifier at http://pootpoot.com/?pootify
The main task which this module performs is attempting to make all the relative links on the filtered page absolute, so that images, and hyperlinks work correctly. It also makes frames and hyperlinks properly filter back through the filter.
This leaves two major tasks for the user of HTML::Munger: fetching the original page, and building a simple munging function.
API
There are really only three important functions you need to know how to call in order to use this module:
- new
- This is a simple constructor, which takes no arguments aside from the implicit class. It returns a blessed reference which is used to call the other methods.
- set_munger
-
This method registers the filtering function you want to be called to produce
the filtered text. The function specified will be called repeatedly with
short blocks of text. For example, given the following HTML:
<P>Hello</P><CENTER>The quick brown <I>fox</I></CENTER>
The filtering function would be called three times, with 'Hello', 'The quick brown ', and 'fox', respectively, as input. The filter function is expected to return a string which will replace the given input in the output of the munge() call. - munge
- This method takes three arguments. The first is the URL of the page which is being munged. Note that the 'munge' method does NOT fetch the page for you! It needs this information in order to make relative links in the page absolute. The second argument is the URL of the filtering program. This is used to make all hyperlinks and frames pass back through the filter. Finally, it takes the input HTML as its third argument. This method returns the munged HTML string, which can then be further parsed or sent to the user.
BUGS
Hopefully none.
AUTHOR
J. David Lowe, dlowe@pootpoot.com
SEE ALSO
perl(1), HTML::Parser(3)