Fetch and parse the directory index from a web server
use WWW::IndexParser; my @files = WWW::IndexParser->new(url => 'http://www.example.com/dir/'); foreach my $entry (@files) { printf "%s %s\n", $entry->filename, scalar(localtime($entry->time)||''); }
WWW::IndexParser is a module that uses \s-1LWP\s0 to fetch a \s-1URL\s0 from a web server. It then atempts to parse this page as if it were an auto generated index page. It returns an array of WWW::IndexParser::Entry objects, one per entry in the directory index that it has found. Each Entry has a set of methods: filename(), time(), size(), and others if supported by the autoindex generated: type() and size_units().
When called with a \s-1URL\s0 to examine, this method does not return an object, but an array of WWW::IndexParser::Entry obects, one per entry in the directory listing that was accessed. The options to this are:
The complete \s-1URL\s0 of the index to fetch.
The timeout for the request to fetch data, default 10 seconds.
A proxy server \s-1URL\s0, eg, 'http://proxy:3128/'.
Decide if to print parsing debug information. Set to 0 (the default) to disable, or anything non-false to print. Recommened you use a digit (ie, 1) as this may become a numeric 'level' of debug in the future.
All methods are private in this module. Pass only a \s-1URL\s0 to the constructor, and it does everything for you itself.
This modile depends upon \*(C`LWP\*(C', \*(C`HTML::Parser\*(C', \*(C`Time::Local\*(C'.
any
Currently only supports Apache, \s-1IIS\s0 and Tomcat style auto indexes. Send suggestions for new Auto-Indexes to support to the author (along with sample \s-1HTML\s0)!
James Bromberger <[email protected]>
Copyright (c) 2006 James Bromberger. All rights reserved. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.