Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: using content-type for judgement

by Utilitarian (Vicar)
on Jun 22, 2011 at 12:26 UTC ( #910897=note: print w/ replies, xml ) Need Help??


in reply to using content-type for judgement

foreach(@urls){ my $ua = LWP::UserAgent->new(); my $url = "$_"; my $response = $ua->head($url); #HTTP::Response type return my $headers = $response->headers(); # HTTP::Headers type return my $content_type =$headers->content_type(); # string print "$content_type\n"; if($content_type eq 'application/pdf'){ print "File Exists:\n $_"; } elsif($content_type eq 'text/html'){ print "File Exists but requires subscription to access:\n"; } elsif ($response->is_success) {{ print "No Idea how to parse $content_type\n""; } else{ print"No Match Found\n"; }
A definitive list of MIME types is an unrealistic goal, however you should be able to draw up a top 50 and handler applications fairly easily.

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."


Comment on Re: using content-type for judgement
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2015-07-28 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls