📜 ⬆️ ⬇️

Creating full-size screenshots of web-resources

A rather useful service is the creation of full-size screenshots of web-resources.
We implement this service in just 5 minutes.

Tasks:


1) Creating full-size screenshots of sites (full screenshot in length and width, and not capture the browser window)
2) web interface

Technology:


- OS - Ubuntu 10.04
- xvfb - Virtual Framebuffer (Fake Xserver)
- CutyCapt - cross-platform utility for rendering web pages
- php - for web-interface

')

Implementation:



- Software installation


1. Installing xvfb

aptitude install xvfb

2. Installing CutyCapt


2.1 Install Subversion first.

aptitude install subversion libqt4-webkit libqt4-dev g ++

2.2 After installing SVN, create a directory for CutyCapt and download the source code:

mkdir / usr / ccapt
cd / usr / ccapt
svn co cutycapt.svn.sourceforge.net/svnroot/cutycapt

Next, proceed to the assembly:

cd cutycapt / CutyCapt
qmake
make

We check the work in the console

xvfb-run - server-args = "- screen 0, 1024x768x24" / usr / ccapt / cutycapt / CutyCapt / CutyCapt --url = http: //habrahabr.ru --out = / var / www / images / habrahabr_ru. jpg

- Web interface


3.1 Let's write a simple php-script for creating screenshots


<? //    $path = '/var/www/images/'; // URL       $web = 'http://kih.kz/images/'; function screenshot($source,$filename) { system('xvfb-run --server-args="-screen 0, 1024x768x24" /usr/ccapt/cutycapt/CutyCapt/CutyCapt --url=http://'.$source.' --out=/var/www/images/'.$filename); } if(!isset($_POST['url'])) { print '<html>'. '<head>'. '<title>  </title>'. '</head>'. '<body>'; print '<form action="" method="post">'. 'URL:<br />'. '<input name="url" type="text" value="http://">'. '<input type="submit" value="Send">'. '</form>'; print '</body>'. '</html>'; } else { //      .   url  host $site = parse_url($_POST['url']); //          $filename = str_ireplace('.','_',$site["host"]).'.jpg'; //     if(file_exists($path.$filename)) { //     -    if (system('find '.$path.' -type f -name '.$filename.' -mtime -1')) { print ',          !<br />'; print '<a href="'.$web.$filename.'">'.$web.$filename.'</a>'; } else { screenshot($site["host"],$filename); print '<a href="'.$web.$filename.'">'.$web.$filename.'</a>'; } } else { screenshot($site["host"],$filename); print '<a href="'.$web.$filename.'">'.$web.$filename.'</a>'; } } ?> 


Conclusion:


In such a rather easy way, we got a handy screenshoter of sites, which perfectly takes screenshots of sites with Flash, and creates a screenshot in full size, but does not cut it to the size of the browser window.

Example:


All actions performed in this article are implemented here .
Temporarily unavailable.

Thanks for attention.

UPD:
In itself, creating a screenshot is quite resource-intensive and requires considerable time costs for creating a screenshot. (of course, depends on the channel of the requested site).
This example is located on a weak VDS, and may not withstand the load.
Therefore, please do not complain if the example is unavailable.

UPD2:
My weak VDS, unfortunately, does not overpower such a load, therefore, most likely the example will be unavailable.

Source: https://habr.com/ru/post/128292/


All Articles