Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: LWP::Simple to judge the url

by moritz (Cardinal)
on Jun 20, 2011 at 09:22 UTC ( #910533=note: print w/replies, xml ) Need Help??


in reply to LWP::Simple to judge the url

If you're not fixed on LWP::Simple, here's an example with Mojolicious:
use Mojo::UserAgent; my $url = "http://de.arxiv.org/pdf/1106.3541" print Mojo::UserAgent->new->head($url)->res->headers->content_type;

This prints application/pdf, indicating that document returned from this URL is a PDF file.

Replies are listed 'Best First'.
Re^2: LWP::Simple to judge the url
by Corion (Patriarch) on Jun 20, 2011 at 09:29 UTC

    (and if you don't have Mojolicious installed, LWP::UserAgent does it as well:)

    use LWP::UserAgent; my $url = "http://de.arxiv.org/pdf/1106.3541"; print LWP::UserAgent->new->head($url)->headers->content_type()

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2023-12-10 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (39 votes). Check out past polls.

    Notices?