使用perl WWW :: Mechanize :: Formfiller填写表单

时间:2012-06-26 05:17:53

标签: perl www-mechanize

我希望从网站http://revigo.irb.hr/下载具有交互式菜单的信息。在使用

获取表单字段后,我正在尝试以下Perl代码
perl -MWWW::Mechanize::Shell -e shell
get http://revigo.irb.hr/
fillout
...
submit
script

最终代码如下:

      use strict;
      use WWW::Mechanize;
      use WWW::Mechanize::FormFiller;
      use URI::URL;

      my @go_terms=qw/GO:0006612 GO:0045862 GO:0048545 GO:0007568 GO:0046326 GO:0051901  GO:0010524 GO:0006044 GO:0032024/;
      my $go_string=join("\n",@go_terms);
      my $agent = WWW::Mechanize->new( autocheck => 1 );
      my $formfiller = WWW::Mechanize::FormFiller->new();
         $agent->env_proxy();

      $agent->get('http://revigo.irb.hr/');
      $agent->form_number(1) if $agent->forms and scalar @{$agent->forms};
      $formfiller->add_filler( 'goList' => Fixed => $go_string);
      $formfiller->add_filler( 'cutoff' => Fixed => '0.4' );
      $formfiller->add_filler( 'isPValue' => Fixed => 'yes' );
      $formfiller->add_filler( 'whatIsBetter' => Fixed => 'higher' );
      $formfiller->add_filler( 'goSizes' => Fixed => '0' );
      $formfiller->add_filler( 'measure' => Fixed => 'SIMREL' );
      $formfiller->fill_form($agent->current_form);

   my $request = $agent->click("startRevigo");
      print $request->as_string;

但是我收到以下错误消息“POST http://revigo.irb.hr/revigo.jsp时出错:revigo.mechanize.pm第21行的内部服务器错误” 有人可以帮我解决问题吗? 提前致谢

1 个答案:

答案 0 :(得分:2)

goSizes必须具有有效值,例如0。您可以使用Firebug轻松地找到它。