Can I 'LOOK' through urllib?

Chris Rebert clp2 at rebertia.com
Wed Feb 11 18:30:53 EST 2009


On Wed, Feb 11, 2009 at 3:17 PM, Muddy Coder <cosmo_general at yahoo.com> wrote:
> Hi Folks,
>
> I feel good after played urllib with fun!
>
> Now I want to LOOK to server through urllib. I read the urllib docs,
> but I did not find such a function. For example, if there are many
> files located in http://www.somedomain.com/data_folder, but I don't
> know what the filenames are residing in the data_folder. I wish urllib
> would have a function to let me do it, as well as I do 'dir' in DOS,
> 'ls' on unix/linux. Somebody write me a demo? Thanks!

No such functionality exists in raw HTTP (i.e. there's no LIST verb
like there is a GET verb), so it's not like Python is erroneously
leaving something out.
You either need cooperation from the server (i.e. it exposes some URL
that gives you `ls`-like output) or the filenames and/or directory
structure need to have some guessable pattern to them so that you can
just run thru the possibilities manually.
So, what you're asking for is impossible in the general case.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list