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

Downloading a file using http

P: 2
Hi, i need to download a file using perl from a website. The link contains the file name so this is complete file address. Earlier i was able to do it using LWA as the file content could be viewed in the browser itself but now when i open the link in my internet browser its asking me to save the file so not showing the content of the file there itself. Could you please tell me how to handle it.
Thanks!
Jul 17 '10 #1
Share this Question
Share on Google+
5 Replies


gpraghuram
Expert 100+
P: 1,275
You can try using curl executable (in windows) or wget (In unix).
Call this from a Perl program and you can easily download the file.

Raghu
Jul 20 '10 #2

P: 2
Hi Raghu,
Is there any possibility if i have the link of a website and that web page contains multiple links with different names. And i want to access any of them. I am trying this in unix.
Thanks!
Jul 20 '10 #3

Expert Mod 100+
P: 589
See:
HTML::LinkExtor - Extract links from an HTML document
http://search.cpan.org/~gaas/HTML-Pa...L/LinkExtor.pm

and:
LWP::Simple - simple procedural interface to LWP
http://search.cpan.org/~gaas/libwww-.../LWP/Simple.pm
Jul 20 '10 #4

100+
P: 115
You could make a system call to linux and read the input. This puts a bit more load on your computer and should not be used if you are going to retrieve many documents. You have more control and a more efficient solution using the LWP package (second part in the code below).



# invoking lynx

$html_code = `lynx -source http://www.yahoo.com/`;
$text_data = `lynx -dump http://www.yahoo.com/`;

# using LWP

use LWP::Simple;
$content = get('http://www.yahoo.com');
Jul 24 '10 #5

numberwhun
Expert Mod 2.5K+
P: 3,503
@Jyoti-Ballabh It sounds like the OP wants to download a file, not the page itself.

My recommendation would be to use the WWW::Mechanize module to download the file. I wrote a similar script using this module a few years ago and use it to this day.
Jul 31 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.