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 3405042
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:27:25+00:00 2026-05-18T05:27:25+00:00

i am very new to Programming and i am just reading the documents. For

  • 0

i am very new to Programming and i am just reading the documents.
For the little project i have read some Perl books and a PHP-Cookbook.
But i have choosen some recipes and believe it or not: it looks pretty awful on the screen. I guess that i now need some assistance –

With my little knowledge is is hard to do the work…i need some Recipes in Mechanize that work, since some of the following examples are outdated:

see the cpan-site for the mechanize examples

i would love to learn more – with real live examples – do you have more ….

i love to hear from you

  • 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-05-18T05:27:25+00:00Added an answer on May 18, 2026 at 5:27 am

    could you be a little more specific on what exactly you are after… For instance this is a script to log into a website:

    use WWW::Mechanize;
    
    my $mech = WWW::Mechanize->new();
    my $url = "http://www.test.com";
    
    $mech->cookie_jar->set_cookie(0,"start",1,"/",".test.com");
    $mech->get($url);
    $mech->form_name("frmLogin");
    $mech->set_fields(user=>'test',passwrd=>'test');
    $mech->click();
    $mech->save_content("logged_in.html");
    

    This is a script to perform google searches

    use WWW::Mechanize;
    use 5.10.0;
    use strict;
    use warnings;
    
    my $mech = new WWW::Mechanize;
    
    my $option = $ARGV[$#ARGV]; 
    
    #you may customize your google search by editing this url (always end it with "q=" though)
    my $google = 'http://www.google.co.uk/search?q='; 
    
    
    my @dork = ("inurl:dude","cheese");
    
            #declare necessary variables
            my $max = 0;
            my $link;
            my $sc = scalar(@dork);
    
            #start the main loop, one itineration for every google search
            for my $i ( 0 .. $sc ) {
    
                #loop until the maximum number of results chosen isn't reached
                while ( $max <= $option ) {
                    $mech->get( $google . $dork[$i] . "&start=" . $max );
    
                    #get all the google results
                    foreach $link ( $mech->links() ) {
                        my $google_url = $link->url;
                        if ( $google_url !~ /^\// && $google_url !~ /google/ ) {
                        say $google_url;
                }
                        }
                         $max += 10;
                    }
    
    
                }
    

    Simple site crawler extracting information (html comments) from every page:

        #call the mechanize object, with autocheck switched off
        #so we don't get error when bad/malformed url is requested
        my $mech = WWW::Mechanize->new(autocheck=>0);
        my %comments;
        my %links;
        my @comment;
    
        my $target = "http://google.com";
        #store the first target url as not checked
        $links{$target} = 0;
        #initiate the search
        my $url = &get_url();
    
        #start the main loop
        while ($url ne "")
        {
            #get the target url
            $mech->get($url);
            #search the source for any html comments 
            my $res = $mech->content;
            @comment = $res =~ /<!--[^>]*-->/g;
            #store comments in 'comments' hash and output it on the screen, if there are any found
            $comments{$url} = "@comment" and say "\n$url \n---------------->\n $comments{$url}" if $#comment >= 0;
            #loop through all the links that are on the current page (including only urls that are contained in html anchor)
    
            foreach my $link ($mech->links())
            {
                $link = $link->url();
                #exclude some irrelevant stuff, such as javascript functions, or external links
                #you might want to add checking domain name, to ensure relevant links aren't excluded
    
                if ($link !~ /^(#|mailto:|(f|ht)tp(s)?\:|www\.|javascript:)/)
                {
                #check whether the link has leading slash so we can build properly the whole url
                $link = $link =~ /^\// ? $target.$link : $target."/".$link;
                #store it into our hash of links to be searched, unless it's already present
                $links{$link} = 0 unless $links{$link};
                }
            }
    
            #indicate we have searched this url and start over
            $links{$url} = 1;
            $url = &get_url();
        }
    
        sub get_url
        {
            my $key, my $value;
            #loop through the links hash and return next target url, unless it's already been searched
            #if all urls have been searched return empty, ending the main loop
    
            while (($key,$value) = each(%links))
            {
                return $key if $value == 0;
            }
    
            return "";
        }
    

    It really depends what you are after, but if you want more examples I would refer you to perlmonks.org, where you can find plenty of material to get you going.

    Definitely bookmark this though mechanize module man page, it is the ultimate resource…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to Perl programming. I've just finished reading the Llama book. Up
I'm very new to programming and I'm just starting to learn VBA with excel.
Im new to programming and I dont know very much about but I'm making
I still very new using Subversion. Is it possible to have a working copy
I am very new to creating webservers - and I have had several goes
I am still very new to Ruby (reading through the Pickaxe and spending most
I am very new to grails.I am doing one sample project for image uploading
I have been programming in Python, PHP, Java and C for a couple or
I'm still very new to programming and I want to write the cleanest code
Im very new to SQL but need to write a query to do the

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.