I would probably use LWP::Simple to verify that the link exists.
use strict; use warnings; use LWP::Simple; my $data_out_file = $ARGV[0] || 'links.txt'; open my $out_handle, '>', $data_out_file or die $!; for my $index ( 0000 .. 1000 ) { my $serial = sprintf "%04s", $index; my $site = qq(http://somewebsite/65081$serial.jpg); sleep 1; next unless head( $site ); my $link = qq(<img src = ") . $site . qq(">); print $out_handle $link, "\n"; } close $out_handle or die $!;
The head() function grabs the document header, which should tell you if it exists or not. In scalar context it simply returns true if successful.
Update: Added sleep 1; to throttle how quickly you'll be hitting the site. It now will take your script 1000 seconds to execute (almost 17 minutes) but you will avoid overloading the remote server. ...always best to play nice.
Dave
In reply to Re: Check links.. if they do exist, then print link to file...but how do i check the existance of a link?(validity?)
by davido
in thread Check links.. if they do exist, then print link to file...but how do i check the existance of a link?(validity?)
by dark314
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |