Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:37:11+00:00 2026-06-14T05:37:11+00:00

I am currently attempting to create a Perl webspider using WWW::Mechanize. What I am

  • 0

I am currently attempting to create a Perl webspider using WWW::Mechanize.

What I am trying to do is create a webspider that will crawl the whole site of the URL (entered by the user) and extract all of the links from every page on the site.

But I have a problem with how to spider the whole site to get every link, without duplicates
What I have done so far (the part im having trouble with anyway):

foreach (@nonduplicates) {   #array contain urls like www.tree.com/contact-us, www.tree.com/varieties....
$mech->get($_);
my @list = $mech->find_all_links(url_abs_regex => qr/^\Q$urlToSpider\E/);  #find all links on this page that starts with http://www.tree.com

#NOW THIS IS WHAT I WANT IT TO DO AFTER THE ABOVE (IN PSEUDOCODE), BUT CANT GET WORKING
#foreach (@list) {
#if $_ is already in @nonduplicates
#then do nothing because that link has already been found
#} else {
#append the link to the end of @nonduplicates so that if it has not been crawled for links already, it will be 

How would I be able to do the above?

I am doing this to try and spider the whole site to get a comprehensive list of every URL on the site, without duplicates.

If you think this is not the best/easiest method of achieving the same result I’m open to ideas.

Your help is much appreciated, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:37:12+00:00Added an answer on June 14, 2026 at 5:37 am

    Create a hash to track which links you’ve seen before and put any unseen ones onto @nonduplicates for processing:

    $| = 1;
    my $scanned = 0;
    
    my @nonduplicates = ( $urlToSpider ); # Add the first link to the queue.
    my %link_tracker = map { $_ => 1 } @nonduplicates; # Keep track of what links we've found already.
    
    while (my $queued_link = pop @nonduplicates) {
        $mech->get($queued_link);
        my @list = $mech->find_all_links(url_abs_regex => qr/^\Q$urlToSpider\E/);
    
        for my $new_link (@list) {
            # Add the link to the queue unless we already encountered it.
            # Increment so we don't add it again.
            push @nonduplicates, $new_link->url_abs() unless $link_tracker{$new_link->url_abs()}++;
        }
        printf "\rPages scanned: [%d] Unique Links: [%s] Queued: [%s]", ++$scanned, scalar keys %link_tracker, scalar @nonduplicates;
    }
    use Data::Dumper;
    print Dumper(\%link_tracker);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently attempting to create a Perl webspider using WWW::Mechanize. What I am
I am attempting to create a bookmarklet that will change the URL of the
I am currently attempting to create a bash script that will check inside of
I'm attempting to create an ASP.NET/C# page that runs a PowerShell script that will
I am attempting to create a manual build in Jenkins that will build a
I am attempting to create an application that will call a remote modem and
I am currently attempting to create a fairly basic web app that has the
I'm attempting to create Data Access Layer for my web application. Currently, all datatables
I'm playing with using Regex to modify Twitter posts. I'm currently attempting to trim
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.