Downloading a file using http

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rinku27
    New Member
    • Jul 2010
    • 2

    Downloading a file using http

    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!
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    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

    Comment

    • Rinku27
      New Member
      • Jul 2010
      • 2

      #3
      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!

      Comment

      • RonB
        Recognized Expert Contributor
        • Jun 2009
        • 589

        #4
        See:
        HTML::LinkExtor - Extract links from an HTML document


        and:
        LWP::Simple - simple procedural interface to LWP

        Comment

        • Jyoti Ballabh
          Banned
          New Member
          • Jul 2010
          • 115

          #5
          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') ;

          Comment

          • numberwhun
            Recognized Expert Moderator Specialist
            • May 2007
            • 3467

            #6
            @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.

            Comment

            Working...