Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Download PDF's

by Godsrock37 (Sexton)
on Jun 19, 2008 at 14:29 UTC ( #692927=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://692927]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-12-02 23:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?