I'm currently working on a little project, which is supposed to crawl the local intranet, and save some meta tags in a DB.
Simple enough, I thought I'd expand my module knowledge and try (the excellent!) WWW::Robot.

However, after a sucessfull start, the program simply stops. No die, no 'out of memory', just stop. This usually occurs after
about 40 pages, though I have been known to reach ~80. Code below, not that long.

#!perl # SMiTZ's Big Bad Support Crawler # crawls support.intel.com, reading title and meta description tags, # storing these in a lovely database. # # v0.1 use strict; use warnings; use WWW::Robot; use DBI; use Data::Dumper; my $docRoot = 'http://support.intel.com'; my $databaseName = 'spider1'; my $databaseTable = 'index'; # Connect to DB my $dbh = DBI->connect("DBI:ODBC:$databaseName", {RaiseError=>1}) or d +ie ("Couldn\'t connect to database: $DBI::errstr; stopped"); my $robot = new WWW::Robot( 'NAME' => 'SMiTZ\'s Bot', 'VERSION' => 0.1, 'EMAIL' => '***@intel.com', 'VERBOSE' => 0, #NAUGHTY BOY!!! Change ASAP 'DELAY' => 0, 'IGNORE_TEXT' => 0); . $robot->proxy('http', 'http://***.***.intel.com:911'); # damn firew +all $robot->addHook('follow-url-test', \&follow_url_test); $robot->addHook('invoke-on-contents', \&invoke_on_contents); $robot->run($docRoot); $dbh->disconnect(); #--------------------------------------------------------------------- +---------------------- # Hook subs sub follow_url_test { my ($robot, $hook, $url) = @_; return 0 unless $url->scheme eq 'http'; return 0 if $url =~ /\.(gif|jpg|png|xbm|au|wav|mpg|doc|xml|ppt)$/; return $url =~ /^$docRoot/; } sub invoke_on_contents { my ($robot, $hook, $url, $response, $structure) = @_; return unless $response->content_type eq 'text/html'; my $desc = $response->header("X-meta-keywords"); $desc = 'none, none, none, none, none' unless ($desc); my $title = $response->header("title"); my @desc = split(/,/, $desc); $dbh->do(q{ INSERT INTO index (url, title, description1, description2, des +cription3, description4, description5) VALUES (?, ?, ?, ?, ?, ?, ?) }, undef, $url, $title, $desc[0], $desc[1], $desc[2], $desc[3], $d +esc[4]) or die $dbh->errstr; print "*"; }
Any ideas what the cause could be? I'd be happy with a RTFM response, as long as anyone could indicate what M.

Thanks muchly in advance,
SMiTZ

In reply to WWW::Robot hangs by smitz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.