From 5a4c3a1a97d64cccb0fa9cfe9b5ba17fb3abcee3 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 20:43:16 -0300 Subject: Support for saving URL as a PNG using wkhtmltoimage --- lib/httracker/functions | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'lib/httracker/functions') diff --git a/lib/httracker/functions b/lib/httracker/functions index 36286d5..7d3b4b5 100644 --- a/lib/httracker/functions +++ b/lib/httracker/functions @@ -66,19 +66,16 @@ function httracker_get { rm -rf $TARGET fi - # Get a screenshot - # https://github.com/paulhammond/webkit2png/ - # https://github.com/adamn/python-webkit2png - # https://snippets.aktagon.com/snippets/504-how-to-generate-screenshots-on-debian-linux-with-python-webkit2png - if [ "$WEBKIT2PNG" == "1" ] && which xvfb-run &> /dev/null; then - xvfb-run -a $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url" - fi - - # Build a PDF + # Save as PDF if [ "$WKHTMLTOPDF" == "1" ] && which xvfb-run &> /dev/null && which wkhtmltopdf &> /dev/null; then xvfb-run -a wkhtmltopdf "$url" $TARGET/screenshot.pdf fi + # Save as PNG + if [ "$WKHTMLTOIMAGE" == "1" ] && which xvfb-run &> /dev/null && which wkhtmltoimage &> /dev/null; then + xvfb-run -a wkhtmltoimage "$url" $TARGET/screenshot.png + fi + # See https://www.insecure.ws/linux/serverless_screenshot.html # http://gfdsa.gfdsa.org/2012/08/15/making-web-pages-screenshots-with-webkit2png-flash-included/ if [ ! -d "$TARGET/screenshot.pdf" ]; then @@ -87,6 +84,16 @@ function httracker_get { fi fi + # Get a screenshot + # https://github.com/paulhammond/webkit2png/ + # https://github.com/adamn/python-webkit2png + # https://snippets.aktagon.com/snippets/504-how-to-generate-screenshots-on-debian-linux-with-python-webkit2png + if [ ! -d "$TARGET/screenshot.png" ]; then + if [ "$WEBKIT2PNG" == "1" ] && which xvfb-run &> /dev/null; then + xvfb-run -a $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url" + fi + fi + # Fix permissions again if [ "`whoami`" != "$USER" ] && [ "`whoami`" == "root" ]; then echo "Fixing $TARGET permissions..." -- cgit v1.2.3