
angeloulivieri
Novice
Mar 21, 2014, 5:45 AM
Post #1 of 11
(6999 views)
|
How to check an URL instead of using HEAD
|
Can't Post
|
|
Hi all, this code on my computer is not working
use LWP::UserAgent; use HTTP::Headers; my $link = "ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/knowledgebase/complete/reldate.txt"; simple_get($link); sub simple_get { my $url = shift; use HTTP::Request; use LWP::UserAgent; my $ua = new LWP::UserAgent; my $request = HTTP::Request->new(HEAD => $url); my $response = $ua->request($request); my $error = 1 unless ($response->is_success); if ($error){ print "There is an error\n"; }else{ print "OK!\n"; } } It returns: There is an error Even if I know that the link is correct, I told to the mantainers of Uniprot.org but they said that for them it's fine. I waswondering if there is a different way from HEAD to check if a URL is working. Because actually I want to check the link and, after a while, download it. For the download I find out the FILE::FETCH module that helped me. For the URL check I can't find anything else... Thank you all Angelo
(This post was edited by FishMonger on Mar 21, 2014, 6:01 AM)
|