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

前端 未结 4 615
长情又很酷
长情又很酷 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:57

    A couple of thoughts.

    1/ You seems to be using the string comparison operators (le, ne) to compare numbers. You should use the numeric comparison operators (<=, !=) instead.

    2/ The value you get back from the LWP::UserAgent::get call is an HTTP::Response object. Judicious use of that class's "is_foo" method might make your code a bit cleaner.

    I don't know if either of these will solve your problem. But they'll improve the quality of your code.

提交回复
热议问题