2

I have app on Heroku and I want to capture webpage and save as image or base64. Problem is: I have node.js script in that app and I want to use phantomjs, but phantom is not compatible with node.

So, I need to capture webpage and save output (image or base64 string) to variable so my primary (node) app can use that values. I tried this but I can't figure how to use that: https://www.npmjs.com/package/phantom

This is what I have so far: (source)

app.get('/capture', function(request, response) {
var phantom = require('phantom');

phantom.create().then(function(ph) {
  ph.createPage().then(function(page) {
    page.open('https://stackoverflow.com/').then(function(status) {
      console.log(status);
      page.property('content').then(function(content) {
           var base64 = page.renderBase64('PNG');

        console.log(base64);
        page.close();
        ph.exit();
      });
    });
  });
});
});

What I need on my heroku server (beside already installed node), what I need to install in node.js, how to use all that? Thanks.

So: send request to capture page -> make image -> pass output to JS variable

Community
  • 1
  • 1
Stfnsn
  • 141
  • 2
  • 13

0 Answers0