Godsrock37 has asked for the wisdom of the Perl Monks concerning the following question:

How would I go about downloading a pdf from the internet?

first off i found the pdf modules and briefly glanced over how to use it, but i have no idea how i would open a url-based pdf to then save locally...

i looked at web fetch but that seemed focused on downloading news and just plain old websites...

any thoughts?

Replies are listed 'Best First'.
Re: Download PDF's
by moritz (Cardinal) on Jun 19, 2008 at 14:35 UTC

      Really?! That's hot. So I could do:

      my $response = $robot->get($url, $url); if ($response->is_success and $response->content_type eq 'application/ +pdf'){ print PDF $contents; }

      how would i get $contents? Some type of parsing?

      I guess that means i can do the same thing with pictures too?

        Even easier:

        use strict; use LWP::Simple qw/getstore/; my $url = "http://blahblah/file.pdf"; my $file = "/home/user/file.pdf"; getstore($url, $file);
        --
        b10m
Re: Download PDF's
by marto (Cardinal) on Jun 19, 2008 at 14:51 UTC
    A nice an easy way would be to use LWP, it provides lwp-download (along with other helpful scripts) which you can either just use as a script, or as a basis for your own script to achieve your goal.

    Hope this helps

    Martin

      thanks marto... i checked it out... now i have a few options. i'll see whats easier and takes up the least processor time and go from there. thanks again