https://github.com/weisjohn/autoindex
parse an autoindex page into JSON (client or server-side)
https://github.com/weisjohn/autoindex
Last synced: over 1 year ago
JSON representation
parse an autoindex page into JSON (client or server-side)
- Host: GitHub
- URL: https://github.com/weisjohn/autoindex
- Owner: weisjohn
- License: mit
- Created: 2014-01-09T19:05:00.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2016-03-24T20:17:40.000Z (over 10 years ago)
- Last Synced: 2025-04-07T08:52:35.847Z (over 1 year ago)
- Language: JavaScript
- Homepage: http://weisjohn.github.io/autoindex/
- Size: 21.5 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# autoindex
parse an autoindex page into JSON (client or server-side)
Ever wanted to take an [autoindex page](http://i.johnweis.com/gifs/ "Something like this") use that data programmatically? Now you can.
### example:
```
autoindex('http://i.johnweis.com/gifs/', function(err, results) {
console.log(results);
})
```
output:
```
root false
parent { href: '/',
url: 'http://i.johnweis.com//',
name: 'Parent Directory',
type: 'dir' }
directories [ { href: 'sample/',
url: 'http://i.johnweis.com/sample/',
name: 'sample/',
type: 'dir',
modified: Thu Jan 09 2014 22:24:00 GMT-0500 (EST) } ]
files [ { href: 'balance.gif',
url: 'http://i.johnweis.com/gifs/balance.gif',
name: 'balance.gif',
type: 'img',
modified: Thu Jan 09 2014 22:17:00 GMT-0500 (EST),
size: '1.0M' },
{ href: 'lemon.gif',
url: 'http://i.johnweis.com/gifs/lemon.gif',
name: 'lemon.gif',
type: 'img',
modified: Thu Jan 09 2014 22:16:00 GMT-0500 (EST),
size: '1.1M' },
{ href: 'yes.gif',
url: 'http://i.johnweis.com/gifs/yes.gif',
name: 'yes.gif',
type: 'img',
modified: Thu Jan 09 2014 22:16:00 GMT-0500 (EST),
size: '473K' } ]
```
### server-side
`npm install autoindex` then:
```
var autoindex = require('autoindex');
```
### client-side
`bower install autoindex` or download the [index.js](index.js) file.
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](http://enable-cors.org) on that site.
### do no evil
If you're going to use this to write webcrawlers, rate-limit yourself.