Why can't I fetch www.google.com with Perl's LWP::Simple?

前端 未结 4 648
长情又很酷
长情又很酷 2021-01-26 09:00

I cant seem to get this peice of code to work:

    $self->{_current_page} = $href;
    my $response = $ua->get($href);
    my $responseCode = $response->         


        
4条回答
  •  忘掉有多难
    2021-01-26 09:52

    You should examine the response code to see what's happening (you're already checking for 404s). I get a 302 - a redirect.

    For example:

    die "get failed ($responseCode): " . $href if (!defined $content);
    

    Resulting message:

    get failed (302): http://www.google.com at goog.pl line 20.
    

提交回复
热议问题