0

I need to make use of Firefox for web scraping. I am using WWW::Mechanize::Firefox. So I will need to install Firefox and Mozrepl however I am installing on a vps that does not have a GUI desktop environment and I am running into problems that Firefox requires a GUI/graphics driver.

The perl script will be run with a cronjob.

How can I do this?

Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
tread
  • 10,133
  • 17
  • 95
  • 170
  • 1
    if you've got command-line access, then use your linux distro's CLI packaging system, e.g. `apt-get install firefox`. – Marc B Feb 03 '14 at 16:43

1 Answers1

3

From the documentation (WWW::Mechanize::Firefox::FAQ):

Do I Need An X Session To Run Firefox?

Yes.

If you run a unixish operating system, like OSX or Ubuntu or some other Linux distribution, then Firefox will connect to your X server and display a window there. If you do not want Firefox to actually display on your monitor, many people have had success by running Firefox on another X server separate from the main X server, like Xvfb.

Personally, I would prefer to have a "headless Firefox" that does not need a windowing environment. So far, I am unaware of this actually existing.

So yes, you need to have an X session available. Enable XForwarding, with ssh, so you can view the remote GUI desktop on your local machine. Then install Firefox via package management, then install MozRepel within Firefox. Once this is done ensure the MozRepel plugin is enabeled. Then use cpan to install the rest:

cpan WWW::Mechanize::Firefox
Dr.Avalanche
  • 1,944
  • 2
  • 28
  • 37
  • If you just want to fake an X-server without actually seeing the output, then [`Xvfb`](https://en.wikipedia.org/wiki/Xvfb) can sometimes be used. – amon Feb 03 '14 at 17:06
  • @amon X is required to calibrade Firefox, install and enable add-ons. Also I've yet to see an working example of WWW::Mechanize::Firefox, e.g. http://www.perlmonks.org/?node_id=962011 – Dr.Avalanche Feb 03 '14 at 17:11