Witam,
Czy z moim kodem jest coś nie tak ? Wydaje się że powinien działać a cały czas mam 500 Can't connect to 145.97.196.166:80 (timeout) albo 500 read timeout albo 504 Gateway Time-outad . Próbuje trafić z czasem. Chyba ze to nie tu jest problem. Jak wpisze to proxy w foxyproxy w firefox to działa.
Przeglądałem sobie inne kody na pastebin ale rozwiązania mają takie same.
#!/usr/bin/perl -w
use LWP::UserAgent;
use LWP::Simple;
use HTTP::Message;
use URI::Escape;
$proxy = 'http://122.72.11.151:80';
my $ua = LWP::UserAgent->new;
#$ua->agent('Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20100101 Firefox/14.0.1');
$ua->agent(' Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0');
$ua->timeout(10); # 30 tez miałem ustawione i było to samo
$ua->proxy(http => $proxy) if defined($proxy);
my $res = $ua->get("http://www.google.com/search?q=perl"); #&start=10
if(!($res->is_success)){
print $res->status_line;
}
else { my @msg = $res->content;
print @msg;
$msg = "@msg";
while($msg =~m/<h3 class=\"r\"><a href=\"(.*?)\"/g){
print $1."\n";
} }