<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="IncrediMail 1.0" name=GENERATOR></HEAD>
<BODY style="BACKGROUND-POSITION: 0px 0px; FONT-SIZE: 12pt; MARGIN: 5px 10px 10px; FONT-FAMILY: Arial" bgColor=#ffffff background="" scroll=yes ORGYPOS="0">
<TABLE id=INCREDIMAINTABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR>
<TD id=INCREDITEXTREGION style="FONT-SIZE: 12pt; CURSOR: auto; FONT-FAMILY: Arial" width="100%">
<DIV> </DIV>
<DIV> </DIV>
<DIV id=receivestrings>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>From:</B></I> <A href="mailto:alan.gauld@freenet.co.uk">Alan Gauld</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Date:</B></I> 03/23/06 11:34:33</DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>To:</B></I> <A href="mailto:kermit@polaris.net">Kermit Rose</A>; <A href="mailto:dyoo@hkn.eecs.berkeley.edu">Danny Yoo</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Cc:</B></I> <A href="mailto:tutor@python.org">tutor@python.org</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Subject:</B></I> Re: [Tutor] urlopen: where are the results?</DIV></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Did you look at the url2lib documentation?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>****</DIV>
<DIV> </DIV>
<DIV>I thought I had, but I did not see the examples.</DIV>
<DIV> </DIV>
<DIV>I did not know enough to make sense of the documentation.</DIV>
<DIV> </DIV>
<DIV>So I thought that I would just try running the urlopen and see what happened.</DIV>
<DIV> </DIV>
<DIV>*****</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>>>> import urllib2</DIV>
<DIV>>>> f = urllib2.urlopen('<A href="http://www.python.org/">http://www.python.org/</A>')</DIV>
<DIV>>>> print f.read(100)</DIV>
<DIV><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"></DIV>
<DIV><?xml-stylesheet href="./css/ht2html</DIV>
<DIV>========================</DIV>
<DIV> </DIV>
<DIV>Which shows how to open and read a web page.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>******</DIV>
<DIV> </DIV>
<DIV>Thanks. I've experimented with the code you've shown me. I feel comfortable with it now.</DIV>
<DIV> </DIV>
<DIV>******</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>And if you went to the index and click 'f' you will find a link</DIV>
<DIV>to 'file object' which gives you the list of methods you can call</DIV>
<DIV>on file objects. (Admittedly not all of them work on file-like</DIV>
<DIV>objects, but most will)</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>**********</DIV>
<DIV> </DIV>
<DIV>How do I get to the index??</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>*****</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>I admit learning how to use the Python document set is not intuitive</DIV>
<DIV>but it's worth persevering and the Module Index is invaluable.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>*****</DIV>
<DIV> </DIV>
<DIV>Eventually I will become expert. Thanks for your help.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Kermit < <A href="mailto:kermit@polaris.net">kermit@polaris.net</A> > </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>*****</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> Alan G</DIV>
<DIV>Author of the learn to program web tutor</DIV>
<DIV><A href="http://www.freenetpages.co.uk/hp/alan.gauld">http://www.freenetpages.co.uk/hp/alan.gauld</A></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></TD></TR>
<TR>
<TD id=INCREDIFOOTER width="100%">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD width="100%"></TD>
<TD id=INCREDISOUND vAlign=bottom align=middle></TD>
<TD id=INCREDIANIM vAlign=bottom align=middle></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>