Can urllib check path exists on server?

2009-02-10 Thread Muddy Coder
Hi Folks,

urllib bridges up a client to a server, it works fine. I wonder: is
there a method that can check the existence of a file in the server
side? We can check such an existence on local filesystem by using
os.path.exists(), can I do such a check on server? For example,
http://somedomain.com/foo/bar.jpg is residing in a hosting server, can
I use urllib to check if bar.jpg file existing or not? Thanks!

Muddy Coder
--
http://mail.python.org/mailman/listinfo/python-list


Can urllib check path exists on server?

2009-02-10 Thread rdmurray
Muddy Coder cosmo_gene...@yahoo.com wrote:
 urllib bridges up a client to a server, it works fine. I wonder: is
 there a method that can check the existence of a file in the server
 side? We can check such an existence on local filesystem by using
 os.path.exists(), can I do such a check on server? For example,
 http://somedomain.com/foo/bar.jpg is residing in a hosting server, can
 I use urllib to check if bar.jpg file existing or not? Thanks!

urllib implements the http protocol for http URLs, so you can only do
what the http protocol allows.  Thus if http://somedomain.com/foo/bar.jpg
is a valid URL on that server, you can do a urlopen, and then check
the 'getcode' method on the returned object to see if you got a '404'
(not found) code back.

--RDM

--
http://mail.python.org/mailman/listinfo/python-list