1

We need a module that gets a url only, and return a screenshot / image of that page without opening it, so it's being done in the background.

All tools i read about here, are doing so by getting a specific div element as an input or redirecting to that page.

It also should fit with a url that has a redirect , so :

function getImageOfPage(url) {

  //get html page of this url (dont show it)
  //wait for page to load all photos
  //create screen shot image

  return img;

}
hkrly
  • 311
  • 3
  • 12
  • Do you want to get a screenshot of a page from a URL, or do you want to get an image from a URL? – yqlim Jul 11 '19 at 06:15
  • you could use html-to-canvas with a hidden iframe or something like that, but some websites will not work due to CORS – madalinivascu Jul 11 '19 at 06:18
  • thanks. i would like to get screenshot of a page from a url. html-to-canvas is done on a div element, i need to get a photo of a fully loaded webpage. – hkrly Jul 11 '19 at 06:33
  • This may help you: https://stackoverflow.com/questions/45172260/scrapy-splash-screenshots#45172646 – Dov Rine Jul 11 '19 at 06:56
  • If it must be javascript, you'll probably have to use Selenium/PhantomJS or something like that. By the way, all of the scrapers do "open" the site by visiting it. I don't think you can get around that. – Dov Rine Jul 11 '19 at 06:57

1 Answers1

1

there's a solution for this you would need node.js, In this, you need the webshot module, npm i webshot

here's a sample code

const webshot = require('webshot');

webshot('https://example.com', 
'img_name.png', function(err) {
    if (!err) {
        console.log("Screenshot taken!")
    }
});
Dharman
  • 30,962
  • 25
  • 85
  • 135