0

我在 perl 中摆弄,我设法从源中检索 HTML 页面。但是我只想检索 1 个特定的行。该行以如下格式的日期开始:dd/mm/YYYY。HTML 显示在 print $resp->content(); $resp 是来自 $mechanice->submit_form() 的响应;这是进行响应的地方:

my $resp = $m->submit_form( 
//bunch of data
},
);

我如何实现这一目标?我熟悉 PHP,但我刚开始使用 Perl。

谢谢

4

1 回答 1

1

这是我拥有的一些机械化代码的示例。

my $mech = WWW::Mechanize->new();
$mech->get("url that takes you to the page with the form");
$mech->submit_form(form_name => 'someform',
                   fields    => {'user_name' => 'user's
                                 'password'  => 'password'},
                   button    => 'submit');

return if not $mech->success();

my $content = $mech->content();
if ($content =~ m|(\d{2,2}/\d{2,2}/\d{4,4}.*)|g) {
  print "My line: $1\n";
}
于 2013-08-28T05:20:46.663 回答