Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I take fullscreen screenshot of website [closed]

I need to get fullscreen shot of website by URL, is there any PHP programs for that or services, if not, is there any Java programs for that purpose?

like image 648
newbie Avatar asked Sep 28 '09 18:09

newbie


3 Answers

There are plenty of ways:

  1. Use http://khtml2png.sourceforge.net/index.php?page=faq

  2. Use webkit engine with some bindings for it: http://www.blogs.uni-osnabrueck.de/rotapken/2008/12/03/create-screenshots-of-a-web-page-using-python-and-qtwebkit/

  3. Use mozilla engine in batch mode: http://www.chimeric.de/blog/2007/1018_automated_screenshots_using_bash_firefox_and_imagemagick

like image 94
Kane Avatar answered Oct 26 '22 16:10

Kane


You need to have a special version of a browser to "render" the page after it's processed by PHP or Java.

You'll most-likely need to set up some custom automation scripts to hit a URL after you ping a server running windows, OSX or a Linux window manager.

There are services out there which will do screen shots for you.

http://www.browsercam.com

http://webthumb.bluga.net/home

to name a few.

like image 24
null Avatar answered Oct 26 '22 15:10

null


The best solution for me: Use selenium webdriver And taking screenshot can be as simple as this:

import java.io.File;
import java.net.URL;

import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class Testing {

    public void myTest() throws Exception {
        WebDriver driver = new RemoteWebDriver(
                                new URL("http://localhost:4444/wd/hub"), 
                                DesiredCapabilities.firefox());

        driver.get("http://www.google.com");

        // RemoteWebDriver does not implement the TakesScreenshot class
        // if the driver does have the Capabilities to take a screenshot
        // then Augmenter will add the TakesScreenshot methods to the instance
        WebDriver augmentedDriver = new Augmenter().augment(driver);
        File screenshot = ((TakesScreenshot)augmentedDriver).
                            getScreenshotAs(OutputType.FILE);
    }
}

Dont forget to use FireFoxDriver. HtmlUnitDriver wont work this way as its headless.

Darn easy!!

like image 32
rahulserver Avatar answered Oct 26 '22 17:10

rahulserver