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?
There are plenty of ways:
Use http://khtml2png.sourceforge.net/index.php?page=faq
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/
Use mozilla engine in batch mode: http://www.chimeric.de/blog/2007/1018_automated_screenshots_using_bash_firefox_and_imagemagick
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.
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!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With