Unix Naive Bare-bone Perl Web Spider: The following is a bare-bone custom depth-level web spider. It does not need any module installed , just the utilitary curl and perl.Does not know to fetch duplicate links.
#!/usr/bin/perl use strict; use warnings; #recursive spider web starting from a page and #specifying depth level #like wget -r --level=... my ($depth_level,$start_page) = @ARGV; exit 1 unless $start_page;#exits if it doesn't have a parameter page t +o download if( !defined $depth_level || $depth_level > 0 ) { my $page_content=`curl $start_page 2>&1`;#takes contents of the pa +ge my @links = $page_content =~ /<a href=([^ ]*?)>/g;#takes out the l +inks from the page for(@links) { print "Working on link $_\n"; my $new_call = "perl naive_crawler.pl ". ($depth_level - 1) ." + $_";#new call for the script with the links from the page `$new_call`; }; }
If you decide to run the script here's how: perl naive_spider.pl 2 "http://code.google.com/hosting/"

In reply to unix perl web spider by spx2

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.