I am trying to use the following in my perl script, can anyone tel me why i am unable to connect. Where am I wrong?

  my $mech = WWW::Mechanize->new();
  $mech->proxy(['http'], 'http://localhost:9050');
  $mech->get("http://blockexplorer.com/q/getreceivedbyaddress/".           $btcaddress);    # Check transactions on my addresses
  my $getreceived = $mech->content;

I have decided to use Net::SOCKS, is this the correct way to implement this into the perl script?

  my $mech = WWW::Mechanize->new();
  my $sock = new Net::SOCKS(socks_addr => '',
            socks_port => 9050,
            user_id => 'the_user',
            user_password => 'the_password',
            force_nonanonymous => 1,
            protocol_version => 5);

  $mech->get("http://blockexplorer.com/q/getreceivedbyaddress/".$btcaddress);   # Check transactions on bitcoin address
  my $getreceived = $mech->content;

  $mech->get("http://blockexplorer.com/q/addressbalance/".$btcaddress);   # Check balance on bitcoin address
  my $addressbalance = $mech->content;

  # send it back to the parent process
  $pm->finish(0, [ $getreceived, $addressbalance, $btcaddress, $private, $passphrase ]);  
  • Tor is not an HTTP proxy, it is a SOCKS proxy.
    – cacahuatl
    Jan 5 '17 at 3:06
  • how would i input that into the above, i have tried replacing http with socks Jan 5 '17 at 6:59
  • I've no idea, you'd need to see if the library supported SOCKS, or just wrap perl with torsocks.
    – cacahuatl
    Jan 5 '17 at 8:23

Exactly like this - citing the code snippet:

use strict;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new(
  agent => q{Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.2.0; .NET 
CLR 1.1.4322)},
$ua->proxy([qw/ http https /] => 'socks://localhost:9050'); # Tor proxy
my $rsp = $ua->get('http://www.yahoo.com/');
print $rsp->content;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.