E
E
Elsa122018-09-22 21:02:05
JavaScript
Elsa12, 2018-09-22 21:02:05

What causes FATAL error in PhantomJS?

Hey! Please help, I wrote a phantomjs script to get a screenshot of the site and the code of its page.

Code here.
var page   = require('webpage').create();
var system = require('system');
var fs     = require('fs');

var url     = system.args[1];
var width   = system.args[2];
var height  = system.args[3];
var outName = system.args[4];

var outNameFile = outName + ".png";
var outNameCode = outName + ".html";

page.viewportSize = { width: width, height: height };
page.clipRect = { top: 0, left: 0, width: width, height: height };

page.open(url, function() {
  page.evaluate(function() {
    var style = document.createElement('style'),
        text = document.createTextNode('body { background: #fff }');
    style.setAttribute('type', 'text/css');
    style.appendChild(text);
    document.head.insertBefore(style, document.head.firstChild);
  });
  
    setTimeout(function() {
            page.render(outNameFile);
            var content = page.content;
           	fs.write(outNameCode, content, 'w');
            phantom.exit();
    }, 2000);

});

But alas, when executing on some addresses, an error is returned to me.
the following content
2018-09-21T12:24:14 [FATAL] Could not initialize GLX
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
Aborted


Moreover, everything works fine on the local machine, but on the server, even with the launch via xvfb-run, everything breaks down. :( How can I explain this and how to fix it? I would be very grateful!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Yumashev, 2018-09-25
@Elsa12

What OS? Probably need to deliver dependencies or required libraries for GLX.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question