check if an URL exists without opening it
Joonas Paalasmaa
joonas.paalasmaa at iki.fi
Sat Aug 10 14:36:49 EDT 2002
More information about the Python-list mailing list
Sat Aug 10 14:36:49 EDT 2002
- Previous message (by thread): check if an URL exists without opening it
- Next message (by thread): Zope Business Rules Engine
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <3d541502$0$549$626a54ce at news.free.fr>, David wrote: > I would like to check if an URL exists. > (for instance http://www.yahoo.com/try.pdf) > > The method urllib.open is unsatisfactory because the URL (which will be a > file in my program) is opened ! So it can take too long time, just to check > the existence ! Use httplib module to issue a HEAD request that downloads only headers, not the actual file. For further information refer to the httplib documentation. http = httplib.HTTP(servername) http.putrequest("HEAD", path) http.putheader("Host", servername) http.endheaders() errcode, errmsg, headers = http.getreply() if errcode == 200: print "file exists"
- Previous message (by thread): check if an URL exists without opening it
- Next message (by thread): Zope Business Rules Engine
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list