By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,538 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,538 IT Pros & Developers. It's quick & easy.

how to call basic browser functions?

P: n/a
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?

thanks in advance,
Bruce
Nov 5 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.)

-Peter
Nov 5 '05 #2

P: n/a
Great! I've never looked in to the urllibs before, but it sounds like
they're just what I need. And no, I'm not thinking of anything so
sophisticated as executing applets or anything -- just those "Save * as
...." functions, where * might be "page", "image", "link target" etc.

I also hadn't known about wget, so that's good to know, too.

thanks!
- bruce

Peter Hansen wrote:
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.)

-Peter

Nov 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.