Skip to content

Instantly share code, notes, and snippets.

@NSEcho
Created March 30, 2021 12:15
Show Gist options
  • Save NSEcho/5160102d9fed77f386f6534fc02fcc3a to your computer and use it in GitHub Desktop.
Save NSEcho/5160102d9fed77f386f6534fc02fcc3a to your computer and use it in GitHub Desktop.
#!/bin/bash
# Create a filename which contains the links you would like to take the screenshot of and pass it as first param.
# Make sure that the urls have correct scheme (http:// or https://)
# The second param is the prefix for screenshots saved.
# Screenshots will be in format: <PREFIX><COUNTER>.png
# Note: Firefox should not be running when running this script.
if [ $# -ne 2 ]; then
echo "You need to provide input file"
echo "./screenshotMe.sh <FILENAME> <SCREENSHOT PREFIX>"
exit 1
fi
GREEN='\033[0;32m'
END='\033[0m'
message() {
echo -e "${GREEN}[*] $1 ${END}"
}
save_screenshot() {
firefox --headless --screenshot "$2$3.png" "$1" > /dev/null 2>&1
}
FILENAME="$1"
PREFIX="$2"
counter=1
while read -r line; do
message "Taking screenshot of ${line}"
save_screenshot "${line}" "${PREFIX}" ${counter}
counter=$((counter+1))
done < "${FILENAME}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment