[Tutor] Visiting a URL

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Fri Nov 1 03:30:02 2002


On Thu, 31 Oct 2002, John Abbe wrote:

> I've got a newbie question -- i'm looking at altering PikiePikie to
> notify weblogs.com when my weblog updates. I could get all involved in
> XML-RPC, but it's doable through a plain URL. How do i visit a URL in
> Python?

Hi John,

Do you mean retrieving the contents of the URL resource?  If so, there's a
nice module called 'urllib' that allows us to open URLs as if they were
files.

    http://python.org/doc/lib/module-urllib.html

There's an example near the bottom that you can try out, and if you have
problems, please feel free to contact the Tutor list again.



There's also a nice set of modules to take the "signature" of a string in
an efficient way, so that, rather than having to save an exact snapshot of
a page, you can just store a shorter signature, and do signature
comparison to see if changes have occurred.  Here's a link to one of these
signature digest modules:

    http://python.org/doc/lib/module-hmac.html

Hmmm... on second thought, using that hmac module might be overkill, but
it's still useful to know that it exists.  *grin*


Good luck!