-2
Ich brauche render Seite zu img. Ich verwende phantomjs, childProcess und cron. Wenn Sie einen anderen Weg kennen - schreiben Sie es bitte. In meiner Art mache ich das nächste, aber es funktioniert nur ein erstes Mal. Hilf mir bitte.rendern Seite auf Phantomjs mit Cron im Knoten
Dies ist cron Code:
var Cron = require('cron').CronJob;
var i = 0;
var job = new Cron({
cronTime: "*/10 * * * * *",
onTick: function() {
console.log("iteration is ", i);
var render = require('../tests/initphantom');
i++;
}
});
job.start();
PhantomJS Code:
var webPage = require('webpage');
var page = webPage.create();
page.viewportSize = {
width: 1920,
height: 5000
};
page.open("http://localhost:3000/", function start(status) {
console.log("status", status);
page.render('test1.jpeg', {
format: 'jpeg',
quality: '100'
});
phantom.exit();
});
und intiate Code:
var path = require('path');
var childProcess = require('child_process');
var phantomjs = require('phantomjs');
var binPath = phantomjs.path;
var childArgs = [
path.join(__dirname, '/phantomTest.js')
]
module.exports.rendr = childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
if (err) {
console.log("err in childProcess", err)
}
});