I would tend to propose that you extend WWW::Mechanize to support having multiple browser sessions.
package WWW::Mechanize::Clones; use strict; use warnings; use Storable 'dclone'; sub WWW::Mechanize::clone { dclone $_[0] } __END__ =head1 NAME WWW::Mechanize::Clones - "fork" browser windows =head1 DESCRIPTION This allows you to "fork" a WWW::Mechanize browser so you can follow m +ultiple links. =head1 SYNOPSIS use WWW::Mechanize; use WWW::Mechanize::Clones; my $browser = WWW::Mechanize->get( ... ); my @browsers = map( { my $new_browser = $browser->clone; $new_browser->follow_link( $_ ); } $browser->find_all_links( ... ) ); =head1 ADDED METHODS =over 4 =item $browser->clone This additional method is added to the WWW::Mechanize class so that yo +u can make a copy of your browser at a point in time. This allows you + to follow multiple links from the same page without having to back t +rack. Here is an example of how to do this without this module: $browser->follow_link( ... ); # do some work $browser->back; $browser->follow_link( ... ); And here is how you can how do this. You no longer have to keep track +of how many times to use ->back to get back to where you can follow t +he other link. my $new_browser = $browser->clone; $browser->follow_link( ... ); $new_browser->follow_link( ... ); =back =cut
In reply to Re: WWW::Mechanize and following multiple links ( use WWW::Mechanize::Clones)
by diotalevi
in thread WWW::Mechanize and following multiple links
by friedo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |