If the web server has turned on directory browsing, it will return an HTML document with links to all files. You can parse the HTML document and extract all the links. This will give you a list of files.
You can use the HTMLParser class to retrieve the elements of interest to you. Something like this will work:
from HTMLParser import HTMLParser
import urllib
class AnchorParser(HTMLParser):
def handle_starttag(self, tag, attrs):
if tag =='a':
for key, value in attrs.iteritems()):
if key == 'href':
print value
parser = AnchorParser()
data = urllib.urlopen('http://somewhere').read()
parser.feed(data)
source
share