urllib2 documentation

Carlos Ribeiro carribeiro at gmail.com
Sat Oct 2 22:11:00 EDT 2004


On Sat, 02 Oct 2004 20:21:47 -0400, Alexander Kervero
<vegeta.z at gmail.com> wrote:
> I am trying to learn urllib2 functionality but it realy lacks
> documentation,the library reference is not enough since this module has a
> very confusing way to work,where can i find examples or tutorials about
> this module,i have googled but no luck?

Well, I agree that some parts of the library are not very well
documented. But urllib2 is *so* simple to use for almost all
situations that it goes almost without the need for documentation. If
all that you need is to read a URL, do it like this:

urlopen("http://somesite.com/somepage")

The result will be a file-liek object, that you can iterate over, or
do a readlines() call, to get the entire resource read. It's really
*that* simple. Check some examples:

http://docs.python.org/lib/urllib2-examples.html

Now, if you want to do something more esoteric, then you have to check
more details in the documentation, and that may be confusing because
urllib2 uses many different classes to support a lot of protocols. But
that's not something that really should worry most users.


-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list