wilstephens has asked for the wisdom of the Perl Monks concerning the following question:
--use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->agent("OpticDB LinkCheck/0.1"); &connect_to_db; my $clock_start = time; # start timer $sth = $dbh->prepare("SELECT * FROM $DB_MYSQL_NAME"); $sth->execute (); my $count = 0; while (my $ref = $sth->fetchrow_hashref ()) { my $req = new HTTP::Request GET => $ref->{'url_en'}; my $res = $ua->request($req); $res_id = $ref->{id}; $res_code = $res->code; $res_msg = $res->message; unless ($res_code eq "200") { $count ++; $tmpl_show_record .= qq| .. html to show erroneous records goes here ... |; } } $num_dead = $count; if ($count == 0) { &error_html("No dead links found!"); exit; } $sth->finish(); my $clock_finish = time - $clock_start; $time_taken = sprintf ("%.2f", $clock_finish); $dbh->disconnect;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checking links with LWP::UserAgent
by lhoward (Vicar) on Feb 26, 2002 at 13:24 UTC | |
by wilstephens (Acolyte) on Feb 26, 2002 at 13:51 UTC | |
by webfiend (Vicar) on Feb 26, 2002 at 23:49 UTC | |
by wilstephens (Acolyte) on Mar 08, 2002 at 10:37 UTC | |
by lhoward (Vicar) on Mar 08, 2002 at 17:27 UTC | |
|
•Re: Checking links with LWP::UserAgent
by merlyn (Sage) on Feb 26, 2002 at 15:02 UTC | |
by wilstephens (Acolyte) on Feb 27, 2002 at 12:05 UTC | |
|
(jeffa) Re: Checking links with LWP::UserAgent
by jeffa (Bishop) on Feb 26, 2002 at 17:39 UTC |