home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
python
/
pyhtmldoc
/
h
/
http_examp
< prev
next >
Wrap
Text File
|
1996-11-14
|
794b
|
21 lines
<TITLE>HTTP Example -- Python library reference</TITLE>
Prev: <A HREF="../h/http_objects" TYPE="Prev">HTTP Objects</A>
Up: <A HREF="../h/httplib" TYPE="Up">httplib</A>
Top: <A HREF="../t/top" TYPE="Top">Top</A>
<H2>10.3.2. Example</H2>
Here is an example session:
<P>
<UL COMPACT><CODE>>>> import httplib<P>
>>> h = httplib.HTTP('www.cwi.nl')<P>
>>> h.putrequest('GET', '/index.html')<P>
>>> h.putheader('Accept', 'text/html')<P>
>>> h.putheader('Accept', 'text/plain')<P>
>>> h.endheaders()<P>
>>> errcode, errmsg, headers = h.getreply()<P>
>>> print errcode # Should be 200<P>
>>> f = h.getfile()<P>
>>> data f.read() # Get the raw HTML<P>
>>> f.close()<P>
>>> <P>
</CODE></UL>