I do not agree with @mariobgr. If there are no server settings prohibiting the directory listing, then the html generated by querying this directory can be parsed for content.
$ tree maindir maindir ├── index.html └── somedir ├── doc1 ├── doc2 └── doc3
index.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"> </script> <title></title> </head> <body> <h1>Listing /somedir</h1> <script> $.get('http://localhost/maindir/somedir', (data) => { console.log(data); let listing = parseDirectoryListing(data); $('body').append(JSON.stringify(listing)); }); function parseDirectoryListing(text) { let docs = text .match(/href="([\w]+)/g) </script> </body>
A visit to localhost/maindir calls:
Listing / somedir
["Doc1", "doc2", "doc3"]
source share