Re: file i/o api for URL

Guido.van.Rossum@cwi.nl
Fri, 13 May 1994 01:08:31 +0200


> I need a file i/o api (you know: open, close, read, seek, ...) for
> URLs. This would give me a simple way to let any application access
> local or remote files. Does anybody have this kind of code already
> or have a suggestion other than hacking it out of the www lib?

If you're willing to write your application in Python, the module
"urllib" would do what you want. Using it, you can do things like

>>> f = urllib.urlopen('http://www.cwi.nl/')
>>> while 1:
... line = f.readline()
... if not line: break # EOF
... print line,
...
(contents of requested url appears here)
>>>

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>