how to call basic browser functions?

Peter Hansen peter at
Sat Nov 5 03:47:09 CET 2005

BLElliott wrote:
> 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 
> answer.
> 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, 
such as Javascript or Java execution, you'll need capabilities far 
beyond what urllib2 can provide.  And you probably don't want to go 
there right now.)


More information about the Python-list mailing list