WebFetch Embedding API |
As of version 0.10 of WebFetch, the Embedding API (application programming interface) was added. WebFetch used to be mostly for use for saving captured web content to files. The purpose of the Embedding API is to allow any Perl program to run a WebFetch module and capture its output for use within that program.
Once the information is available to other programs, there are as many possibilities as Perl allows for what to do with it. So the Embedding API delivers on the implied promise that came from packaging WebFetch as Perl5 modules instead of scripts. Instead of just saving the information to files, now it's available within a program too.
Old WebFetch 0.09 and earlier modules continue to work in what is called ``0.09 compatibility mode''. Actually, the old strucutres are still there so it's more than just compatibility - the new Embedding API is triggered by the presence of new variables which contain more information.
The following modules were converted to the new API in WebFetch 0.10: CNETnews, CNNsearch, COLA, Freshmeat, SiteNews, and Slashdot.
The remaining modules have not been converted yet and operate in 0.09 compatibility mode: DebianNews, General, LinuxDevNet, LinuxTelephony, ListSubs, PerlStruct, 32BitsOnline and YahooBiz. Upcoming WebFetch releases will convert more until all the modules are done.
Modules that users have written for WebFetch 0.09 and earlier which are not (yet) distributed with WebFetch should also continue to work unmodified. If they don't, that would be a bug and should be reported.
In WebFetch 0.09 and earlier, each module was responsible for saving its own information to a file, for all file formats that they supported. Now the module saves to some predefined variables. If the module was called from WebFetch's core command-line routines, the core will handle saving the files in all requested formats. If the module was called from another program, now it has the option to look inside the returned data and do its own processing with it.
A WebFetch module which implements the Embedding API must define the following variables, which are defined in more detail in the WebFetch core module documentation:
Programs which need to use this data can read it directly from the records and fields in $obj->{data}{records}. Some sample code is shown in the WebFetch FAQ at http://www.webfetch.org/
A module which inherits from WebFetch and fails to provide these variables is assumed to be a WebFetch 0.09 module. Any module in WebFetch 0.09 compatibiltily mode is responsible to save its own HTML or other files.
WebFetch Embedding API |