home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / h / http_examp < prev    next >
Text File  |  1996-11-14  |  794b  |  21 lines

  1. <TITLE>HTTP Example -- Python library reference</TITLE>
  2. Prev: <A HREF="../h/http_objects" TYPE="Prev">HTTP Objects</A>  
  3. Up: <A HREF="../h/httplib" TYPE="Up">httplib</A>  
  4. Top: <A HREF="../t/top" TYPE="Top">Top</A>  
  5. <H2>10.3.2. Example</H2>
  6. Here is an example session:
  7. <P>
  8. <UL COMPACT><CODE>>>> import httplib<P>
  9. >>> h = httplib.HTTP('www.cwi.nl')<P>
  10. >>> h.putrequest('GET', '/index.html')<P>
  11. >>> h.putheader('Accept', 'text/html')<P>
  12. >>> h.putheader('Accept', 'text/plain')<P>
  13. >>> h.endheaders()<P>
  14. >>> errcode, errmsg, headers = h.getreply()<P>
  15. >>> print errcode # Should be 200<P>
  16. >>> f = h.getfile()<P>
  17. >>> data f.read() # Get the raw HTML<P>
  18. >>> f.close()<P>
  19. >>> <P>
  20. </CODE></UL>
  21.