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

标签 perl login web mechanize scrape

我在 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    => 'xyz@gmail.com',
            Passwd  =>'xyz'
        }
    );
print $re->content();

当我运行代码时,它说:

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

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

最佳答案

代理有问题:

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

该程序无需调用代理方法即可为我工作。去掉这个。

关于perl - 使用 WWW::Mechanize 在 perl 中进行站点抓取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11406791/

相关文章:

http - 断开连接后使netcat丢弃所有字节

regex - 删除一个字符的单词

perl - 全局符号 "@str"需要显式包名称

wordpress - woocommerce 通过rest api验证用户名和密码

login - 使用 MVC 在 Sitecore 7.1 中实现自定义登录

javascript - 自定义 pdf.js

perl - 异常 : Please criticize my code 后重试操作

perl - DBD::Firebird 编码/解码

python - Django : How can I implement a remember me key on my login page

testing - Spring Boot Web 应用的负载测试工具