how to call basic browser functions?
peter at engcorp.com
Sat Nov 5 03:47:09 CET 2005
> I think this is a very basic question, so feel free to direct me to a
> FAQ or other resource to go and get myself educated, if that's the best
> Can I perform web browser functions from a script, for example, doing
> file downloads, if I can construct the file URL within my script? As an
> example, suppose there's a file I download periodically, but its URL
> changes with the current date. If I can write a script that will
> automatically generate the URL, can it then go and fetch the file for me?
Yes, you can definitely do that. Look for examples of using "urllib" or
"urllib2". There should be many that are close to the sort of thing you
want. Or you could simply use a command line utility such as "wget" to
accomplish much the same thing and avoid almost any programming.
(Note that if in addition to downloading the actual contents of the
page, you will require more sophisticated features of a real browser,
beyond what urllib2 can provide. And you probably don't want to go
there right now.)
More information about the Python-list