【问题标题】:Perl submit to a page, then submit againPerl 提交到一个页面,然后再次提交
【发布时间】:2012-07-01 14:08:40
【问题描述】:

我有以下代码:

$IEDocument = $IE->{Document};
$Forms = $IEDocument->all;
$form = $forms->item{'search');
$form->click;

# it clicks the search button which submits to a page
# then I do the following

$doc = $IE->{Document}; #Not sure if correct
$forms = $doc->{DocumentElement}->{InnerHTML};
$form = $forms->item('field');
$form->{value} = "12345";

# The following code must submit to a page, then put new info in an input field on that new submitted page

但它不起作用,有什么方法可以做到这一点?我研究了这么多,有人建议使用 WWW::Mechanize,但是当我使用它时,我无法截取页面,因为 Mechanize 只是在 CMD 中显示它在做什么,并没有真正打开浏览器。 (顺便说一句,有没有办法用 WWW::Mechanize 打开浏览器,看看实际发生了什么?)

【问题讨论】:

  • 为什么需要截图?
  • 我需要一张来自它提交到的页面的图片

标签: perl


【解决方案1】:

请提供一些细节关于它是如何实现的

没用

要截屏,您可以使用 WWW::Mechanize::Firefox 模块:

use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
$mech->get('http://google.com');

my $png = $mech->content_as_png(); #you have a screen in $png now

【讨论】:

  • 这真的很好,但我想要屏幕的某些部分而不是整个屏幕。 WWW::Mechanize 也能做到这一点吗?还要安装`WWW::Mechanize::Firefox`我做cpan WWW::Mechanize::Firefox
  • 另外,这会打开浏览器并执行您的操作吗?或者它在 CMD 中执行(条款不是很好)
  • 对不起,我所说的“屏幕”仅指目标站点屏幕截图。您所说的“某些部分”是什么意思?你还需要cpan install WWW::Mechanize::Firefox。安装后你需要对你的 Firefox 做一些调整(安装 Mozrepl 插件)
  • 假设我想从 100x100 坐标开始截取 300x300 像素
  • Grigor,它有助于read the documentation 您正在使用的软件。
猜你喜欢
  • 2017-09-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-13
  • 1970-01-01
  • 2012-03-05
相关资源
最近更新 更多