Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Perl: how to save an image from a URL?

Options
  • 15-04-2007 4:30pm
    #1
    Registered Users Posts: 2,364 ✭✭✭


    Can someone tell me how I can download and save an image using a perl script if I have the URL of the image?

    Does the Mechanize library allow this, or will it only save information about the image?

    Cheers


Comments

  • Registered Users Posts: 2,364 ✭✭✭Mr. Flibble


    I got it
    use LWP::Simple;
    
    my $picture_binary = get "http://domain.com/logo.gif";
    
    open (SAVE, "./local_copy.gif");
    binmode SAVE;
    print SAVE $picture_binary;
    close (SAVE);
    


  • Registered Users Posts: 2,364 ✭✭✭Mr. Flibble


    Actually I haven't got it.

    This code seems to only work on images which are hosted on the same server which the script is running from. When I try it on other images it saves an image of the URL for the image which seems very odd. Anyone know what is going on here?


Advertisement