简体   繁体   English

是否可以通过WWW :: Mechanize :: Firefox单击Javascript弹出窗口?

[英]Is it possible to click on a Javascript pop-up window with WWW::Mechanize::Firefox?

I'll try to make myself as clear as possible. 我会尽力使自己尽可能清楚。 I want to download automatically a file. 我想自动下载文件。 What I've done so far: 到目前为止,我所做的是:

use WWW::Mechanize::Firefox;
use Crypt::SSLeay;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
$url = $url.@ARGV[0]; 
my $mech = WWW::Mechanize::Firefox->new;
$mech->get( $url );
$mech->form_name('sysinfo');
$mech->click_button( name => 'download' );

When I click that button a window pops up, because of an onclick() js event. 当我单击该按钮时,由于一个onclick() js事件,将弹出一个窗口。 It asks what I want to do with the file, so I need to click the Save button. 它询问我要如何处理该文件,因此我需要单击“ 保存”按钮。 The thing is I can't get the window to do it. 关键是我无法打开窗口进行操作。 I can't use get because the only URL I know is the one that pops the new window up. 我不能使用get,因为我知道的唯一URL是弹出新窗口的URL。 I've couldn't find something similar. 我找不到类似的东西。 So is it possible to do what I want? 那么可以做我想做的吗? or is there other way? 还是还有其他方法? I'd appreciate any help, thank you. 感谢您的帮助,谢谢。

What is function on onclick()? 什么是onclick()函数? Maybe you can try paste this in url bar javascript:function_on_onclick(param1, param2); 也许您可以尝试将其粘贴到网址栏中javascript:function_on_onclick(param1, param2);

If it will be works, try $mech->get('javascript:function_on_onclick(param1, param2);'); 如果$mech->get('javascript:function_on_onclick(param1, param2);'); ,请尝试$mech->get('javascript:function_on_onclick(param1, param2);');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM