Website Screenshot mit Linux

This post was published 12 years 9 months 17 days ago, so the post may be outdated.

Nach einer langen und qualvollen Suche mit Google, bin ich auf eine Lösung gestoßen wie man mit Linux eine Webseite screenen und als PNG (jpg, usw..) abspeichern lassen kann.

Der Screenshot kann unter den Bildformaten svg, png, jpeg, gif und bmp abgespeichert werden.

Um die nächsten Pakete zu installieren, müssen wir den Paketmanager aptitude installieren. Dies geht so:
apt-get install -y aptitude

Nun installieren wir weitere benötigte Pakete:
aptitude install g++ subversion build-essential libgl1-mesa-dri xvfb libqt4-webkit libqt4-dev xfonts-scalable xfonts-100dpi xfs

Nun laden wir uns das benötigte Programm, welches die Websiten screent, herunter, entpacken es und installieren es abschließend:
svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt # Herunterladen
cd cutycapt/CutyCapt # In das Verzeichnis wechseln
qmake # Compilieren
make # Compilieren

Nach diesen Befehlen gibt es nun eine Datei namens “CutyCapt”.
Nun machen wir die Datei ausführbar:
chmod +x CutyCapt

Mit CutyCapt kann man jetzt ganz leicht – mit einem Befehl – eine Website screenen und als PNG abspeichern:
xvfb-run --server-args="-screen 0, 1366x768x24" ./CutyCapt --url=https://patrik.kernstock.net --out=pkern_at.png
Die Website “https://patrik.kernstock.net” wird nun als PNG unter den Namen pkern_at.png gespeichert.
Der Screenshot hat eine Auflösung von 1366×768.

Mit wenig PHP Kenntnissen und einem Webspace/Server wo SaveMode aus ist, kann man sich ein kleines Script schreiben.
Achtung: Das Script ist eine 3 Minuten Arbeit und nicht besonders sicher. Höchstens für Eigengebrauch.
[php collapse=”true”]<?php
if(isset($_POST[‘submit’]) && $_POST[‘check’]==true)
{
$screen_dir = "./screens"; # Without slash (/) at the end!
$size = $_POST[‘size’];

$size = explode("x", $size);
$width = $size[0];
$height = $size[1];

$link = $_POST[‘url’]; # Link of the page?
$name = str_replace("http://", "", $link);
$file = $screen_dir."/".$name.".png";

if(!file_exists($file)) shell_exec(‘xvfb-run –server-args="-screen 0, ‘.$width.’x’.$height.’x24" ./app/CutyCapt –url=’.$link.’ –out=’.$file);

}
?>
<html>
<head>
<title>Screener</title>
</head>
<body>
<?php
if(empty($file))
{
if(empty($_POST[‘url’])) $url = "http://www."; else $url = $_POST[‘url’];
echo ‘
<form action="" method="post">
<b>Homepage</b> <small>(URL)</small>:<br />
<input type="text" name="url" value="’.$url.’" size="50"><br />
<br />
<b>Screen-Size</b>:<br />
<select name="size">
<option value="1366×768">1366×768</option>
<option value="1024×768">1024×768</option>
</select>
<br />
<br />
<b>Notice</b><br />
A shot of a page may take some seconds! (~10seconds)<br />
<br />
<input type="checkbox" name="check"> I agree that my IP <small>(‘.$_SERVER[‘REMOTE_ADDR’].’)</small> will be saved.<br />
<br />
<input type="submit" name="submit" id="submit" value="Shot the page!">
</form>
‘;
}
else {
echo ‘<img src="’.$file.’">’;
}
?>
</body>
</html>[/php]

Viel Spaß beim Snapschüsse machen!

Patrik Kernstock

May I introduce my self? I am Patrik Kernstock, 25 years old, perfectionist, born in Austria and living in Ireland, Cork. Me explained in short: Tech- and security enthusiast, series & movies junky. Interesting in Linux, Container-stuff and many software solutions by Microsoft, Veeam and VMware.

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
newest
oldest most voted
Inline Feedbacks
View all comments
Wuuz

apt-get install -y aptitude <- epic fail.

2
0
Would love your thoughts, please comment.x
()
x