[Tutor] Listing web contents

Joseph J. Strout joe@strout.net
Fri, 26 Mar 1999 12:50:12 -0800


At 12:36 PM -0800 03/26/99, Jon Cosby wrote:

>Hi - Is there any way of listing the directory contents of a URL address?
>Something like
>
>dir = urllib.urlopen(url)
>os.listdir(dir)

No.  A URL address does not refer to a file.  It refers to a document,
which may (if the server so chooses) represent a listing of files, but it's
still a document.  Asking "how to list the directory contents of a URL
address" doesn't make sense.  Your example would be equivalent to:

f = open("somefile.txt")
os.listdir(f)

Cheers,
-- Joe
,------------------------------------------------------------------.
|    Joseph J. Strout           Biocomputing -- The Salk Institute |
|    joe@strout.net             http://www.strout.net              |
`------------------------------------------------------------------'