[Tutor] urlopen: where are the results?

Kermit Rose kermit at polaris.net
Fri Mar 24 17:27:26 CET 2006

From: Alan Gauld
Date: 03/23/06 11:34:33
To: Kermit Rose; Danny Yoo
Cc: tutor at python.org
Subject: Re: [Tutor] urlopen: where are the results?
Did you look at the url2lib documentation?


I thought I had,  but I did not see the examples.

I did not know enough to make sense of the documentation.

So I thought that I would just try running the urlopen and see what happened

>>> import urllib2
>>> f = urllib2.urlopen('http://www.python.org/')
>>> print f.read(100)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?xml-stylesheet href="./css/ht2html
Which shows how to open and read a web page.


Thanks.   I've experimented with the code you've shown me.   I feel
comfortable with it now.


And if you went to the index and click 'f' you will find a link
to 'file object' which gives you the list of methods you can call
on file objects. (Admittedly not all of them work on file-like
objects, but most will)


How do I get to the index??


I admit learning how to use the Python document set is not intuitive
but it's worth persevering and the Module Index is invaluable.


Eventually I will become expert.    Thanks for your help.

Kermit   <   kermit at polaris.net  >  


  Alan G
Author of the learn to program web tutor

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060324/1a29c2fd/attachment.htm 

More information about the Tutor mailing list