0

I'm trying to set the ip address in lwp::useragent so I tried the following. But it throws the following error

Can't connect to www.some_domain.com:443

LWP::Protocol::https::Socket: bind: Cannot assign requested address at /usr/local/share/perl/5.18.2/LWP/Protocol/http.pm line 47.

I don't know how to fix it. My code is as follow

use LWP::UserAgent;
my $url = "https://www.some_domain.com";
my $ua = LWP::UserAgent->new();
$ua->local_address("152.73.205.80");
my $response = $ua->get($url);
$cont = $response->content;

print $cont;

How can I fix it.?

mkHun
  • 5,891
  • 8
  • 38
  • 85
  • Why are you trying to set the IP address? What are you trying to do? – ysth Dec 14 '16 at 07:47
  • @ysth I'm trying to crawl the content from the site. But the site has the captcha when opening from the same IP. – mkHun Dec 14 '16 at 10:10

1 Answers1

1

LWP::Protocol::https::Socket: bind: Cannot assign requested address...

local_address needs to be an IP address of the machine where the code is running on. If this is not the case, i.e. if you want to use some external address (like the target IP address) instead of the local address, you get exactly this error message.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172