简体   繁体   English

我如何获得WWW ::机械化工作?

[英]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 GET http://www.google.com时出错:无法在D:\\ PERL \\ try.pl第5行连接到www.google.com:80(连接:未知错误)

What's wrong? 怎么了?

From your error message I see that you're on a Windows box (D:\\PERL\\try.pl). 从错误消息中,我看到您在Windows框上(D:\\ PERL \\ try.pl)。 Maybe the Windows firewall doesn't trust Perl to access the internet and blocks its traffic? 也许Windows防火墙不信任Perl访问互联网并阻止其流量?

You might get lucky adding a rule allowing perl.exe access to the internet in the Windows firewall. 在Windows防火墙中添加允许perl.exe访问Internet的规则可能会让您很幸运。

Did it work before? 以前有用吗? This code works on my Linux box. 此代码可在我的Linux机器上使用。

  1. It could be that you have no internet connection. 可能是您没有互联网连接。
  2. Maybe Google blocked you. 也许Google阻止了您。

可能像Olfan所说的那样成为防火墙,或者您可能需要在环境中使用代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM