如何使用Perl填写Web表单?

时间:2022-11-20 21:38:03

I want to fill in a web form with Perl. I am having trouble finding out the correct syntax to accomplish this. As in, how do I go to the URL, select the form, fill in the form, and then press enter to be sure it has been submitted?

我想用Perl填写一个Web表单。我无法找到正确的语法来完成此任务。如何,我如何转到URL,选择表单,填写表格,然后按Enter以确保它已被提交?

5 个解决方案

#1


Something like WWW::Mechanize::FormFiller?

像WWW :: Mechanize :: FormFiller这样的东西?

#2


WWW::Mechanize and its friends are the way to go. There are several examples in Spidering Hacks, but you'll also find plenty more by googling for the module name.

WWW :: Mechanize及其朋友是要走的路。 Spidering Hacks中有几个例子,但你也会通过谷歌搜索模块名称找到更多。

Good luck, :)

祝好运, :)

#3


Start with WWW::Mechanize::Shell:

从WWW :: Mechanize :: Shell开始:

perl -MWWW::Mechanize::Shell -e shell
get http://some/page
fillout
...
submit

Afterwards, type "script", and save generated code as something.pl - and that's about it. It's done.

然后,键入“script”,并将生成的代码保存为something.pl - 就是这样。完成。

#4


Request the form's action URL with Net::HTTP or something (can't recall the exact module), and include the forms fields as a GET/POST parameter (whichever the form calls for).

使用Net :: HTTP或其他东西(不能回忆确切的模块)请求表单的操作URL,并将表单字段包含为GET / POST参数(无论表单要求哪个)。

#5


HTML::Form works nicely, too.

HTML :: Form也很好用。

The synopsis of the module is an excellent example:

该模块的概要是一个很好的例子:

 use HTML::Form;
 $form = HTML::Form->parse($html, $base_uri);
 $form->value(query => "Perl");

 use LWP::UserAgent;
 $ua = LWP::UserAgent->new;
 $response = $ua->request($form->click);

#1


Something like WWW::Mechanize::FormFiller?

像WWW :: Mechanize :: FormFiller这样的东西?

#2


WWW::Mechanize and its friends are the way to go. There are several examples in Spidering Hacks, but you'll also find plenty more by googling for the module name.

WWW :: Mechanize及其朋友是要走的路。 Spidering Hacks中有几个例子,但你也会通过谷歌搜索模块名称找到更多。

Good luck, :)

祝好运, :)

#3


Start with WWW::Mechanize::Shell:

从WWW :: Mechanize :: Shell开始:

perl -MWWW::Mechanize::Shell -e shell
get http://some/page
fillout
...
submit

Afterwards, type "script", and save generated code as something.pl - and that's about it. It's done.

然后,键入“script”,并将生成的代码保存为something.pl - 就是这样。完成。

#4


Request the form's action URL with Net::HTTP or something (can't recall the exact module), and include the forms fields as a GET/POST parameter (whichever the form calls for).

使用Net :: HTTP或其他东西(不能回忆确切的模块)请求表单的操作URL,并将表单字段包含为GET / POST参数(无论表单要求哪个)。

#5


HTML::Form works nicely, too.

HTML :: Form也很好用。

The synopsis of the module is an excellent example:

该模块的概要是一个很好的例子:

 use HTML::Form;
 $form = HTML::Form->parse($html, $base_uri);
 $form->value(query => "Perl");

 use LWP::UserAgent;
 $ua = LWP::UserAgent->new;
 $response = $ua->request($form->click);