node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



parse an autoindex page into JSON (client or server-side)

Ever wanted to take an autoindex page use that data programmatically? Now you can.


autoindex('', function(err, results) {


root false
parent { href: '/',
  url: '',
  name: 'Parent Directory',
  type: 'dir' }
directories [ { href: 'sample/',
    url: '',
    name: 'sample/',
    type: 'dir',
    modified: Thu Jan 09 2014 22:24:00 GMT-0500 (EST) } ]
files [ { href: 'balance.gif',
    url: '',
    name: 'balance.gif',
    type: 'img',
    modified: Thu Jan 09 2014 22:17:00 GMT-0500 (EST),
    size: '1.0M' },
  { href: 'lemon.gif',
    url: '',
    name: 'lemon.gif',
    type: 'img',
    modified: Thu Jan 09 2014 22:16:00 GMT-0500 (EST),
    size: '1.1M' },
  { href: 'yes.gif',
    url: '',
    name: 'yes.gif',
    type: 'img',
    modified: Thu Jan 09 2014 22:16:00 GMT-0500 (EST),
    size: '473K' } ]


npm install autoindex then:

var autoindex = require('autoindex');


autoindex works with or without jQuery. If you need legacy browser support, make sure to add jQuery to your page. To use autoindex, simply add it to your page via a <script> tag or use RequireJS.

NOTE: If you wish to use this in the browser, enable CORS on that site.

do no evil

If you're going to use this to write webcrawlers, rate-limit yourself.