Search code examples
screenshotcutycapt

capture web page using cutycapt or PhantomJs?


I want to take screenshot from my web automatically using crontab. I have installed cutycapt on my server. But I get this error when running it :

enter image description here

My question is :

  1. What's wrong with that error ?
  2. What is the best way to capture screenshot of my web page, cutycapt or phantomjs ?
  3. What is needed to use cutycapt or phantomjs ? I don't understand how cutycapt or phantomjs works.

I'll be grateful if there is any one who can explain this to me. Thanks.


Solution

  • To get it to work in a "headless" environment I used xvfb, I'd already installed xserver, but I do not believe it is required. I did not intentionally install phantomjs, but it may be a dependancy.

    sudo apt-get install xvfb cutycapt
    

    And I then launched cutycapt in an xvfb framebuffer and sent some arguments. This is taken from the cutycapt source forge usage page.

    xvfb-run --server-args="-screen 0, 1024x768x24" cutycapt --url=website.com --out=image.png
    

    I also wrote a little script to make it even easier. It asks you which page to download. saves it as as the the url.png

    #!/bin/bash
    echo what is the website you would like to grab?
    read url
    echo grabbing $url please wait...
    xvfb-run --server-args="-screen 0, 1024x768x24" cutycapt --url=$url --out=$url.png
    echo done, image is $url.png