User1611
User1611

Reputation: 1099

How do I get WWW::Mechanize to work?

This script:

use strict;
use warnings;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new( autocheck => 1 );

$mech->get( "http://www.google.com" );
print $mech->content;

Produces this error message:

Error GETing http://www.google.com: Can't connect to www.google.com:80 (connect: Unknown error) at D:\PERL\try.pl line 5

What's wrong?

Upvotes: 1

Views: 1060

Answers (3)

innaM
innaM

Reputation: 47909

Might be your firewall like Olfan said or you might need to have to use a proxy in your environment.

Upvotes: 1

Olfan
Olfan

Reputation: 579

From your error message I see that you're on a Windows box (D:\PERL\try.pl). Maybe the Windows firewall doesn't trust Perl to access the internet and blocks its traffic?

You might get lucky adding a rule allowing perl.exe access to the internet in the Windows firewall.

Upvotes: 7

Peter Stuifzand
Peter Stuifzand

Reputation: 5104

Did it work before? This code works on my Linux box.

  1. It could be that you have no internet connection.
  2. Maybe Google blocked you.

Upvotes: 3

Related Questions