简体   繁体   English

WWW:Mechanize:Firefox连接失败

[英]WWW:Mechanize:Firefox fails connection

I am creating a short Perl Script. 我正在创建一个简短的Perl脚本。 I am using the WWW::Mechanize::Firefox module. 我正在使用WWW::Mechanize::Firefox模块。 When I instantiate the object, I believe the module fails to establish a connection with the MozRepl component in Firefox. 当我实例化对象时,我相信模块无法与Firefox中的MozRepl组件建立连接。

My code is as follows: 我的代码如下:

use WWW::Mechanize::Firefox;

my $mech = WWW::Mechanize::Firefox->new();

When I run the code, I get the following error message 当我运行代码时,我收到以下错误消息

Failed to connect to , problem connecting to "localhost", port 4242: Connection refused at /usr/local/share/perl/5.12.4/MoxRepl/Client.pm line 144'

I just installed and updated all relevant software I can think of 我刚刚安装并更新了我能想到的所有相关软件

  1. Perl 5.12.4 Perl 5.12.4
  2. MozRepl Extension for Firefox 适用于Firefox的MozRepl扩展
  3. CPAN CPAN
  4. MozRepl MozRepl
  5. WWW::Mechanize WWW ::机械化
  6. WWW::Mechanize::Firefox WWW ::机械化::火狐

I tried adjusting the firewall to open port 4242. Nothing is working. 我尝试调整防火墙以打开端口4242.没有什么工作。 Any ideas? 有任何想法吗?

A similar error code appears in this Stack Overflow question 此Stack Overflow问题中出现类似的错误代码


Update 更新

Ok, Borodin's answer actually fixed 2 problems. 好吧,鲍罗丁的答案实际上解决了2个问题。

WWW::Mechanize::Firefox->new() only works when WWW :: Mechanize :: Firefox-> new()仅适用于

  1. The Firefox browser is already open, and Firefox浏览器已经打开,并且
  2. After starting Firefox, you follow Borodin's instructions and also start MozRepl 启动Firefox后,按照Borodin的说明操作,并启动MozRepl

I had expected the Perl script to act like a shell script, and start Firefox for me. 我曾期望Perl脚本像shell脚本一样,并为我启动Firefox。 This is not the case. 不是这种情况。

Also, if you hide the menu bar in Firefox, the "Tools" menu is the only menu that is not accessible in the drop-down list that appears on the top left. 此外,如果您在Firefox中隐藏菜单栏,则“工具”菜单是唯一一个在左上角显示的下拉列表中无法访问的菜单。 You have to show the menu bar to access the "Tools" menu. 您必须显示菜单栏才能访问“工具”菜单。

You need to start the MozRepl add-on in Firefox. 您需要在Firefox中启动MozRepl插件。

Go to Tools / MozRepl and click on Start 转到Tools / MozRepl并单击Start

Your program should now work. 你的程序现在应该可行。

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

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