"Dody R. Wicaksono" wrote:
> 
> Saya ingin gunakan method HEAD (biar cepat) untuk buat fasilitas cek broken
> link. Ada saran? Atau biar mudahnya pakai Perl saja ya, trus PHP akan

#!/usr/bin/perl

use Getopt::Std;
use HTML::LinkExtor;
use LWP::UserAgent;

getopts('b:p:t:');

$ua = new LWP::UserAgent;
$ua->timeout($opt_t || 60);
$ua->proxy('http', $opt_p) if $opt_p;

$p = HTML::LinkExtor->new(\&cb, $opt_b);

sub cb {
    my($tag, %links) = @_;
        my ($url) = values(%links);
        
        if (not exists($all{$url})) {
            my $res = $ua->request(new HTTP::Request('HEAD', $url)); 
                $all{$url}++;
                print $url, ": ", $res->code, "\n";                                    
 
        }
}

$p->parse_file($ARGV[0]);


contoh: 
$ ./cb -bhttp://dicoba.to namafile.html

Jangan lupa install modul URI, supaya bisa absolutisasi relative links.

Regards,
Edwin.

-- 
Belajar sejarah? 
http://history.perl.org

--------------------------------------------------------------------------------
Utk berhenti langganan, kirim email ke [EMAIL PROTECTED]
Informasi arsip di http://www.linux.or.id/milis.php3
Pengelola dapat dihubungi lewat [EMAIL PROTECTED]

Kirim email ke