
Ein einfaches Skript, um Screenshots einer Liste von Websites zu erstellen.
Ein einfaches Skript, um eine Liste von Webseiten zu screenshoten, basierend auf dem url-to-image PhantomJS-Skript.
--ignore-certificate-errors Option nicht funktioniert und nie wieder funktionieren wird: Die Lösung ist die Verwendung eines ordentlichen Webdrivers, aber bis heute unterstützt webscreenshot diese ziemlich komplexe Methode mit Tools von Drittanbietern nicht.ImageMagick)Geben Sie Ihre Ziele in eine Textdatei und übergeben Sie sie mit der Option -i, oder als Positionsargument, wenn Sie nur eine einzelne URL haben.
Screenshots werden standardmäßig in Ihrem aktuellen ./screenshots/-Verzeichnis abgelegt.
Akzeptierte Eingabeformate sind die folgenden:
http(s)://domain_or_ip:port(/resource)
domain_or_ip:port(/resource)
domain_or_ip(/resource)
webscreenshot.py version 2.96
usage: webscreenshot [-h] [-i INPUT_FILE] [-o OUTPUT_DIRECTORY] [-w WORKERS] [-v] [--no-error-file] [-z SINGLE_OUTPUT_FILE] [-p PORT]
[-s] [-m] [-r {phantomjs,chrome,chromium,edge,firefox}] [--renderer-binary RENDERER_BINARY] [--no-xserver]
[--window-size WINDOW_SIZE] [-f {pdf,png,jpg,jpeg,bmp,ppm}] [-q [0-100]] [--ajax-max-timeouts AJAX_MAX_TIMEOUTS]
[--crop CROP] [--custom-js CUSTOM_JS] [-l] [--label-size LABEL_SIZE] [--label-bg-color LABEL_BG_COLOR]
[--imagemagick-binary IMAGEMAGICK_BINARY] [-c COOKIE] [-a HEADER] [-u HTTP_USERNAME] [-b HTTP_PASSWORD]
[-P PROXY] [-A PROXY_AUTH] [-T PROXY_TYPE] [-t TIMEOUT]
[URL]
options:
-h, --help show this help message and exit
Hauptparameter:
URL Einzelnes URL-Ziel als Positionsargument
-i, --input-file INPUT_FILE
<INPUT_FILE> Textdatei, die die Zielliste enthält. Bsp.: list.txt
-o, --output-directory OUTPUT_DIRECTORY
<OUTPUT_DIRECTORY> (optional): Ausgabeverzeichnis für Screenshots (Standard './screenshots/')
-w, --workers WORKERS
<WORKERS> (optional): Anzahl der parallelen Arbeitsprozesse (Standard 4)
-v, --verbosity <VERBOSITY> (optional): Ausführlichkeitsgrad, wiederholen zum Erhöhen { -v INFO, -vv DEBUG } (Standard
Ausführlichkeit ERROR)
--no-error-file <NO_ERROR_FILE> (optional): Keine Datei mit der Liste der URLs fehlgeschlagener Screenshots schreiben (Standard false)
-z, --single-output-file SINGLE_OUTPUT_FILE
<SINGLE_OUTPUT_FILE> (optional): Name einer Datei, die die einzige Ausgabe aller Eingaben darstellt. Bsp. test.png
Parameter zur Eingabeverarbeitung:
-p, --port PORT <PORT> (optional): Den angegebenen Port für jedes Ziel in der Eingabeliste verwenden. Bsp: -p 80
-s, --ssl <SSL> (optional): SSL/TLS für jede Verbindung erzwingen
-m, --multiprotocol <MULTIPROTOCOL> (optional): Screenshots über HTTP und HTTPS für jedes Ziel durchführen
Parameter des Screenshot-Renderers:
-r, --renderer {phantomjs,chrome,chromium,edge,firefox}
<RENDERER> (optional): Zu verwendender Renderer unter 'phantomjs' (veraltet, aber beste Ergebnisse), 'chrome', 'chromium',
'edge', 'firefox' (Version > 57) (Standard 'phantomjs')
--renderer-binary RENDERER_BINARY
<RENDERER_BINARY> (optional): Pfad zur Renderer-Ausführbaren, falls es nicht in $PATH gefunden werden kann
--no-xserver <NO_X_SERVER> (optional): Falls Sie ohne X-Server arbeiten, wird xvfb-run zum Ausführen des Renderers verwendet
(standardmäßig wird versucht, zu erkennen, ob die Umgebungsvariable DISPLAY existiert)
Parameter des Screenshot-Bildes:
--window-size WINDOW_SIZE
<WINDOW_SIZE> (optional): Breite und Höhe der Bildschirmaufnahme (Standard '1200,800')
-f, --format {pdf,png,jpg,jpeg,bmp,ppm}
<FORMAT> (optional, nur phantomjs): Bildausgabeformat angeben, "pdf", "png", "jpg", "jpeg", "bmp"
oder "ppm" (Standard 'png')
-q, --quality [0-100]
<QUALITY> (optional, nur phantomjs): Bildqualität angeben, eine ganze Zahl zwischen 0 und 100 (Standard
75)
--ajax-max-timeouts AJAX_MAX_TIMEOUTS
<AJAX_MAX_TIMEOUTS> (optional, nur phantomjs): Pro AJAX-Anfrage und maximale URL-Timeout in Millisekunden
(Standard '1400,1800')
--crop CROP <CROP> (optional, nur phantomjs): Rechteck <t,l,w,h> zum Zuschneiden der Bildschirmaufnahme (Standard auf WINDOW_SIZE:
'0,0,w,h'), nur Zahlen, w(idth) und h(eight). Bsp. "10,20,w,h"
--custom-js CUSTOM_JS
<CUSTOM_JS> (optional, nur phantomjs): Pfad einer Datei, die JavaScript-Code enthält, der vor dem
Erstellen des Screenshots ausgeführt wird. Bsp: js.txt
Parameter des Screenshot-Labels:
-l, --label <LABEL> (optional): Für jeden Screenshot einen weiteren erstellen, der die Ziel-URL anzeigt (erfordert
imagemagick)
--label-size LABEL_SIZE
<LABEL_SIZE> (optional): Schriftgröße für das Label (Standard 60)
--label-bg-color LABEL_BG_COLOR
<LABEL_BACKGROUND_COLOR> (optional): Hintergrundfarbe des Labels in ImageMagick (Standard NavajoWhite)
--imagemagick-binary IMAGEMAGICK_BINARY
<LABEL_BINARY> (optional): Pfad zur ImageMagick-Binärdatei (magick oder convert), falls sie nicht in $PATH gefunden werden kann
HTTP-Parameter:
-c, --cookie COOKIE <COOKIE_STRING> (optional): Cookie-String zum Hinzufügen. Bsp: -c "JSESSIONID=1234; YOLO=SWAG"
-a, --header HEADER <HEADER> (optional): Benutzerdefinierter oder zusätzlicher Header. Wiederholen Sie diese Option für jeden Header. Bsp: -a "Host:
localhost" -a "Foo: bar"
-u, --http-username HTTP_USERNAME
<HTTP_USERNAME> (optional): Benutzername für HTTP Basic Authentication angeben.
-b, --http-password HTTP_PASSWORD
<HTTP_PASSWORD> (optional): Passwort für HTTP Basic Authentication angeben.
Verbindungsparameter:
-P, --proxy PROXY <PROXY> (optional): Proxy angeben. Bsp: -P http://proxy.company.com:8080
-A, --proxy-auth PROXY_AUTH
<PROXY_AUTH> (optional): Authentifizierungsinformationen für den Proxy bereitstellen. Bsp: -A user:password
-T, --proxy-type PROXY_TYPE
<PROXY_TYPE> (optional): Gibt den Proxy-Typ an, "http" (Standard), "none" (komplett deaktivieren), oder
"socks5". Bsp: -T socks
-t, --timeout TIMEOUT
<TIMEOUT> (optional): Timeout für die Renderer-Ausführung in Sekunden (Standard 30 Sek.)
list.txt
--------
http://google.fr
https://216.58.213.131
216.58.213.131
https://duckduckgo.com/robots.txt
Standardausführung mit einer Liste
-----------------------------
$ python webscreenshot.py -i list.txt
webscreenshot.py version 2.3
[+] 4 URLs to be screenshot
[+] 4 actual URLs screenshot
[+] 0 error(s)
Standardausführung mit einer einzelnen URL
-----------------------------------
$ python webscreenshot.py -v google.fr
webscreenshot.py version 2.3
[INFO][General] 'google.fr' has been formatted as 'http://google.fr:80' with supplied overriding options
[+] 1 URLs to be screenshot
[INFO][http://google.fr:80] Screenshot OK
[+] 1 actual URLs screenshot
[+] 0 error(s)
Erhöhung der Ausführlichkeitsstufe
-----------------------------------
$ python webscreenshot.py -i list.txt -v
webscreenshot.py version 2.3
[INFO][General] 'http://google.fr' has been formatted as 'http://google.fr:80' with supplied overriding options
[INFO][General] 'https://216.58.213.131' has been formatted as 'https://216.58.213.131:443' with supplied overriding options
[INFO][General] '216.58.213.131' has been formatted as 'http://216.58.213.131:80' with supplied overriding options
[INFO][General] 'https://duckduckgo.com/robots.txt' has been formatted as 'https://duckduckgo.com:443/robots.txt' with supplied overriding options
[+] 4 URLs to be screenshot
[INFO][https://duckduckgo.com:443/robots.txt] Screenshot OK
[INFO][http://216.58.213.131:80] Screenshot OK
[INFO][https://216.58.213.131:443] Screenshot OK
[INFO][http://google.fr:80] Screenshot OK
[+] 4 actual URLs screenshot
[+] 0 error(s)
Ergebnisse
-------
$ ls -l screenshots/
total 187
-rwxrwxrwx 1 root root 53805 May 19 16:04 http_216.58.213.131_80.png
-rwxrwxrwx 1 root root 53805 May 19 16:05 http_google.fr_80.png
-rwxrwxrwx 1 root root 53805 May 19 16:04 https_216.58.213.131_443.png
-rwxrwxrwx 1 root root 27864 May 19 16:04 https_duckduckgo.com_443_robots.txt.png
Hier nicht aufgeführte Optionen werden von allen derzeitigen Renderern unterstützt.
pip install webscreenshot und dann direkt $ webscreenshot verwendenpip install -r requirements.txt ausführen, dann python webscreenshot.pyxvfb, wenn Sie webscreenshot in einem headless-Betriebssystem ausführen möchten: Verwenden Sie die Option --no-xserver von webscreenshot, um alles zu vereinfachenImageMagick-Binärdatei (magick oder convert), falls Sie URLs mit der Option in Screenshots einbetten möchten: Folgen Sie der webscreenshot ist freie Software: Sie können es unter den Bedingungen der GNU General Public License, wie von der Free Software Foundation veröffentlicht, entweder Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren Version, weiterverbreiten und/oder modifizieren.
webscreenshot wird in der Hoffnung verteilt, dass es nützlich ist, jedoch OHNE JEGLICHE GEWÄHRLEISTUNG; ohne die stillschweigende Gewährleistung der MARKTGÄNGIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
Weitere Details finden Sie in der GNU General Public License.
Sie sollten zusammen mit webscreenshot eine Kopie der GNU General Public License erhalten haben. Falls nicht, siehe http://www.gnu.org/licenses/.
| Optionskategorie | Option | PhantomJS-Renderer | Chromium / Chrome / Edge Chromium-Renderer | Firefox-Renderer |
|---|
| Screenshot-Parameter | ||||
format (-f) | Ja | Nein | Nein | |
quality (-q) | Ja | Nein | Nein | |
Ajax- und Anfrage-Timeouts (--ajax-max-timeouts) | Ja | Nein | Nein | |
Zuschneiden (--crop) | Ja | Nein | Nein | |
Benutzerdefiniertes JavaScript (--custom-js) | Ja | Nein | Nein | |
| HTTP-Parameter | ||||
Cookie (-c) | Ja | Nein | Nein | |
Header (-a) | Ja | Nein | Nein | |
http_username (-u) | Ja | Nein | Nein | |
http_password (-b) | Ja | Nein | Nein | |
| Verbindungsparameter | ||||
Proxy (-P) | Ja | Ja | Nein | |
Proxy-Authentifizierung (-A) | Ja | Nein | Nein | |
Proxy-Typ (-T) | Ja | Ja | Nein | |
| Möglichkeit, eine HTTPS-Website mit einem nicht öffentlich signierten Zertifikat zu screenshoten | Ja | Nein | Nein |
--label