thttpd-index-parser

Parse thttpd index pages

thttpd-index-parser

Parse thttpd index pages

There's really not much to say. thttpd provides a stable, if ugly, autoindex page. I have reason to parse this page. The rest is history.

$ npm install thttpd-index-parser

OR

$ git clone git://github.com/deoxxa/thttpd-index-parser.git node_modules/thttpd-index-parser

This is about it. There's not much to know.

#!/usr/bin/env node
 
var parser = require("thttpd-index-parser"),
    request = require("request");
 
request("http://somewhere/with/a/list", function(errresdata) {
  console.log(parser.parse(data.toString()));
});

parser.parse returns an array of objects, one for each entry in the list. The structure of those objects is as follows.

A file:

{
  "url": "http://a.fully.qualified.domain/and/the/whole/path",
  "time": new Date("Sun Sep 16 2012 00:33:35 GMT+1000 (EST)"),
  "size": 12345,
}

A directory:

{
  "url": "http://same.as.above/but/the/path/ends/in/a/slash/",
  "time": new Date("Sun Sep 16 2012 00:33:35 GMT+1000 (EST)"),
  "size": null,
}

3-clause BSD. A copy is included with the source.