Skip to content

Instantly share code, notes, and snippets.

@paulera
Created April 19, 2018 16:11
Show Gist options
  • Save paulera/b58a948b143a35ad690058877cdd6728 to your computer and use it in GitHub Desktop.
Save paulera/b58a948b143a35ad690058877cdd6728 to your computer and use it in GitHub Desktop.
Script to find all <script src="...."> in a URL source code
#!/bin/bash
if [ -z $1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "Usage: "$(basename $0)" <url>"
echo
echo "This script finds all external scripts referred by <script> tags"
exit 1
fi
curl -L -s "$1" | tr '\r\n\t' ' ' | sed $'s/\(<\/[^>]*>\)/\\1\\\n/g' | sed 's/^ *//;s/ *$//' | grep "^<script" | grep --color=always "src=[\"'][^\"']\+[\"']" | while read i; do echo -e $i"\n"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment