#!/usr/bin/perl
use strict;
use LWP::UserAgent;
my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5');
$ua->proxy('http' => 'socks://188.26.223.189:1080');
my $response = $ua->get('http://example.com');
print $response->code,' ', $response->message,"\n";
print $response->decoded_content . "\n";
我尝试通过socks-proxy连接到网站,但是我收到错误:500无法连接到example.com:80 我做错了什么?
答案 0 :(得分:1)
这可能意味着三件事之一:
LWP::Protocol::socks
使用IO::Socket::Socks
作为SOCKS库。因此,您可以通过定义SOCKS_DEBUG
环境变量来打开调试:
SOCKS_DEBUG=1 perl test.pl
这将显示SOCKS握手。所以你可能会看到这次握手成功与否(https://www.ietf.org/rfc/rfc1928.txt)。
您也可以尝试直接通过IO::Socket::Socks
进行连接,看看它是否会成功:
perl -MIO::Socket::Socks -E 'IO::Socket::Socks->new(ProxyAddr => "188.26.223.189", ProxyPort => 1080, ConnectAddr => "example.com", ConnectPort => 80, Timeout => 30, SocksDebug => 1) or die $SOCKS_ERROR; say "Connected!"'