The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WWW::Mechanize::Tor - rotate your ips

VERSION

version 0.01

SYNOPSIS

use WWW::Mechanize::Tor;

my $mech = WWW::Mechanize::Tor->new(
    tor_control_port => 9051,            # empty port on default range(49152 .. 65535)
    tor_port         => 9050,            # empty port on default range(49152 .. 65535)
    tor_ip           => '127.0.0.1',     # localhost on default
    tor_config       => 'path/to/torrc', # tor default config path
);

if ($mech->rotate_ip) {
    say 'got another ip';
}
else {
    say 'Try again?';
}

DESCRIPTION

Inherits directly form LWP::UserAgent::Tor instead of LWP::UserAgent. Launches tor proc in background and connects to it via socket. Every method call of rotate_ip will send a request to change the exit node and return 1 on sucess.

METHODS

rotate_ip

$mech->rotate_ip;

Try to get another exit node via tor. Returns 1 for success and 0 for failure.

ACKNOWLEDGEMENTS

Inspired by a script of ac0v overcoming some limitations (no more!) of web scraping...

LICENSE

This is released under the Artistic License.

AUTHOR

spebern <bernhard@specht.net>