WWW::IndexParser(3pm)
π NAME π
WWW::IndexParser β fetch and parse the directory index from a web server.
Ok bestie, real talk: this is a user contributed Perl doc, the 3pm kind, and it's here to teach you how to grab a web server's directory listing and turn it into actual usable objects. Slay.
β¨ SYNOPSIS β¨
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)||'');
}
Look at that. Two lines and you're already printing filenames and timestamps. Iconic behavior. π
π¦ DESCRIPTION π¦
So WWW::IndexParser is a module that uses LWP to fetch a URL from a web server. Then it atempts to parse that page as if it were an auto generated index page. (Yes, the original says "atempts" β we're keeping the vibe, it's canon. π«Ά)
It hands you back an array of WWW::IndexParser::Entry objects, one per entry in the directory index it managed to find. No cap.
Each Entry has a lil set of methods: filename(), time(), size(), and β if the autoindex that generated the page supports it β type() and size_units(). Not every index is gonna give you the extra credit, and that's fine.
π CONSTRUCTOR π
new ( url => $url, timeout => $seconds, proxy => $proxy_url, debug => 1 )
When you call this with a URL to examine, it does not return an object. Not a typo, not a glitch β it returns an array of WWW::IndexParser::Entry obects, one per entry in the directory listing that was accessed. It's giving "surprise, you got a whole list instead of one thing." π₯
The options to this are:
urlβ the complete URL of the index to fetch.timeoutβ the timeout for the request to fetch data. Default is10seconds.proxyβ a proxy server URL, eg,'http://proxy:3128/'.debugβ decides if it prints parsing debug information. Set it to0(the default) to disable, or anything non-false to print. The docs recommend you use a digit (ie,1) because this may become a numeric 'level' of debug in the future. So like, future-proof yourself bestie, use a number. β
πΈ METHODS πΈ
All methods are private in this module. Pass only a URL to the constructor, and it does everything for you itself. It's the main character β let it cook. π
π§ PREREQUISUTES π§
This modile depends upon LWP, HTML::Parser, Time::Local.
Yeah the section heading is spelled "PREREQUISUTES" and the sentence says "modile". We do not fix these. We honor them. It's the lore. π
π OSNAMES π
any β it runs wherever, it's flexible like that. β¨
π BUGS π
Currently it only supports Apache, IIS and Tomcat style auto indexes. If your server does something else, it's not gonna know what to do with that page.
Got suggestions for new Auto-Indexes to support? Send them to the author β along with sample HTML! Seriously, bring the receipts, they can't build a parser out of vibes alone. π¨
π«Ά AUTHOR π«Ά
James Bromberger <james@rcpt.to>
π COPYRIGHT π
Copyright (c) 2006 James Bromberger. All rights reserved. All rights reserved. (yes, twice, they said it with their whole chest π )
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
β SEE ALSO β
Hmm, actually there's no SEE ALSO section in this one bestie, so nothing to link here. Go read the source, it's right there. π
And that's the whole page, fr fr. This was WWW::IndexParser(3pm) from the perl docs β perl v5.32.1, dated 2021-12-15. Screenshot it, bookmark it, tattoo it, whatever you gotta do. Byeee π¦β¨
π¦ where this page comes from
- debian bookworm: libwww-indexparser-perl 0.91-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libwww-indexparser-perl 0.91-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libwww-indexparser-perl 0.91-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libwww-indexparser-perl 0.91-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libwww-indexparser-perl 0.91-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libwww-indexparser-perl 0.91-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms