good day dear php-fans at stackoverflow.
i want to use imagegrabscreen — to get Captures of the whole screen – well i need a PHP-script that scrapes 500 different sites and stores the results as thumbnails
This example that i have tested and shown below – it demonstrates how to take a screenshot of the current screen and save it as a png image.
as a base for a webscraper that runs with PHP and collects images i thought we-.
note – all i need are previews or thumbnails i do not need fully fledged images.
<?php
$im = imagegrabscreen();
imagepng($im, "myscreenshot.png");
imagedestroy($im);
?>
This example demonstrates how to take a screenshot of the current screen and save it as a png image.
well – to spell it out. i need approx 500 to 1000 webshots ( images that are stored as thumbnails with 240 pixels at the long distance at maximum.
i think it should be pretty obvious but I’ll mention it anyway, if we re running GPU-intensive applications (not CPU), calling this function will cause quite some significant lag to our machine and server response until the request is complete.
For this to work our Apache service must be set to ‘Allow service to interact with desktop’ otherwise we will just get a blank image.
Question: how to implement the long list of 500 URLS that i have to visit and create a thumbnails?
You’ll need some interface to access a browser(s) through PHP so you can capture the image. Selenium is probably the most complete implementation of this, and it already has screenshot capturing abilities. They’ve also implemented distributed processing to make this process as fast as possible.
http://seleniumhq.org/docs/05_selenium_rc.html