I'm writing a service in Go and I'm using phantomJS to generate an image from a given url. From my Go program, I'm using Exec
to start the phantomJS binary. This works fine, but now I'm looking for a way to pass the complete code, together with the call which runs the binary. My code is as follows:
var args = require('system').args;
var webPage = require('webpage');
var page = webPage.create();
page.viewportSize = {
width: 1920,
height: 1080
};
page.open("http://www.url2fetch.com", function (status) {
var base64 = page.renderBase64('PNG');
console.log(base64);
phantom.exit();
});
This never changes. Except the url to fetch :). So my concrete question is: is it possible to start phantomJS and pass the code above as a parameter so it can be executed with one call. Reason for this: I don't want to package the phantomjs script together with my Go program.