help: downloading online files with perl

K

kk

Hi,
I am trying to write a script that downloads a file from a website everyday.
Can I just use the copy command (i.e. use File::Copy)? Does it support URI?
I wrote something like below, but it does not seem to work.

use File::Copy;
copy(www.abc.com\abc.pdf, "C:\myfolder\") or die "File cannot be copied.";

Is there a better way to do this?

Sorry, it seems like a very easy thing to do, but I am doing something
wrong...

Thank you
 
J

Jürgen Exner

kk said:
I am trying to write a script that downloads a file from a website
everyday.

Your Question is Asked Frequently:
"How do I fetch an HTML file?"
Can I just use the copy command (i.e. use File::Copy)?
No.

Does it support URI?

Well, of course not. A URI can be anything, not just a simple file.
I wrote something like below, but it does not seem to
work.
use File::Copy;
copy(www.abc.com\abc.pdf, "C:\myfolder\") or die "File cannot be
copied.";
Is there a better way to do this?

Yes. As explained in the FAQ.

jue
 
V

Verizon

kk said:
Hi,
I am trying to write a script that downloads a file from a website
everyday. Can I just use the copy command (i.e. use File::Copy)? Does it
support URI? I wrote something like below, but it does not seem to work.

use File::Copy;
copy(www.abc.com\abc.pdf, "C:\myfolder\") or die "File cannot be copied.";

Is there a better way to do this?

Sorry, it seems like a very easy thing to do, but I am doing something
wrong...

Thank you
Have a look at LWP (lib-www-perl). You'll probably need to do an HTTP
request, but it supports ftp, gopher and local file systems using this
module. I haven't tried this with what you're trying to do so I don't have
any examples, but I have used LWP to retrieve HTTP pages.

Craig
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top