Looping through a directory on the web and displaying its contents (files and other directories) via

Posted by al jaffe on Stack Overflow See other posts from Stack Overflow or by al jaffe
Published on 2010-05-25T19:10:22Z Indexed on 2010/05/25 19:11 UTC
Read the original article Hit count: 249

Filed under:
|
|
|
|

In the same vein as http://stackoverflow.com/questions/2593399/process-a-set-of-files-from-a-source-directory-to-a-destination-directory-in-pyth I'm wondering if it is possible to create a function that when given a web directory it will list out the files in said directory. Something like...

files[]

for file in urllib.listdir(dir):
    if file.isdir:
        # handle this as directory
    else:
        # handle as file

I assume I would need to use the urllib library, but there doesn't seem to be an easy way of doing this, that I've seen at least.

© Stack Overflow or respective owner

Related posts about python

Related posts about file