diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-03-25 20:43:16 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-03-25 20:43:16 -0300 |
commit | 5a4c3a1a97d64cccb0fa9cfe9b5ba17fb3abcee3 (patch) | |
tree | d8040137d8f69412fb6206ce69c801e1c01aad95 /lib/httracker/functions | |
parent | 567c3ea429d7d4f02ff8bff51f0a540dbcb8aed0 (diff) | |
download | httruta-5a4c3a1a97d64cccb0fa9cfe9b5ba17fb3abcee3.tar.gz httruta-5a4c3a1a97d64cccb0fa9cfe9b5ba17fb3abcee3.tar.bz2 |
Support for saving URL as a PNG using wkhtmltoimage
Diffstat (limited to 'lib/httracker/functions')
-rw-r--r-- | lib/httracker/functions | 25 |
1 files changed, 16 insertions, 9 deletions
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..." |