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

LWP::UserAgent::Tor - rotate your ips

SYNOPSIS

use LWP::UserAgent::Tor;

my $ua = LWP::UserAgent::Tor->new(
    tor_control_port => 9051,            # empty port on default range(49152 .. 65535)
    tor_port         => 9050,            # empty port on default range(49152 .. 65535)
    tor_config       => 'path/to/torrc', # tor default config path
);

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

DESCRIPTION

Inherits directly form 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

$ua->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>