how to call basic browser functions?

B

BLElliott

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
 
P

Peter Hansen

BLElliott said:
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
 
B

BLElliott

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top