Skip to content

Instantly share code, notes, and snippets.

@aozimkov
Forked from pix0r/scrape-sitemap.sh
Created October 11, 2019 16:30
Show Gist options
  • Save aozimkov/5c70d5da224128fb5e32ed6c24dae2cb to your computer and use it in GitHub Desktop.
Save aozimkov/5c70d5da224128fb5e32ed6c24dae2cb to your computer and use it in GitHub Desktop.
Use wget to scrape all URLs from a sitemap.xml Usage: scrape-sitemap.sh http://domain.com/sitemap.xml
#!/bin/sh
SITEMAP=$1
if [ "$SITEMAP" = "" ]; then
echo "Usage: $0 http://domain.com/sitemap.xml"
exit 1
fi
XML=`wget -O - --quiet $SITEMAP`
URLS=`echo $XML | egrep -o "<loc>[^<>]*</loc>" | sed -e 's:</*loc>::g'`
echo $URLS | tr ' ' '\n' | wget -O /dev/null -i - --wait=1 --random-wait -nv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment