使用 WWW::Mechanize 在 Perl 中进行站点抓取

问题描述 投票:0回答:1

我在 Perl 中使用 WWW::Mechanize 进行网站抓取应用程序。

当我要通过 WWW::Mechanize 登录特定站点时,我遇到了一些困难。我已经了解了 WWW::Mechanize 的一些示例。但我找不到我的问题。 我在下面提到了我的代码。

#!/usr/bin/perl -w

use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use Crypt::SSLeay;
my $agent = WWW::Mechanize->new(noproxy => 0);
$agent->cookie_jar(HTTP::Cookies->new());
$agent->agent('Mozilla/5.0');
$agent->proxy(['https', 'http', 'ftp'], 'http://proxy.rcapl.com:3128');
$agent->get("http://www.facebook.com");
my $re=$agent->submit_form(
        form_number => 1,
        fields      => {
            Email    => '[email protected]',
            Passwd  =>'xyz'
        }
    );
print $re->content();

当我运行代码时,它说:

发布错误 https://www.facebook.com/login.php?login_attempt=1:未在 ./test.pl 第 11 行实现

任何人都可以告诉代码出了什么问题吗?我需要设置 facebook 发送的所有登录参数吗?.

authentication perl web-scraping mechanize
1个回答
1
投票

代理有故障:

Error GETing http://www.facebook.com: Can't connect to proxy.rcapl.com:3128 (Bad hostname) at so11406791.pl line 11. 

该程序适用于我,无需调用代理方法。删除这个。

© www.soinside.com 2019 - 2024. All rights reserved.