Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Simple script for downloading program stored on CNET:
# - AOMEI Partition Assistant Standard
# Tested on 2013-11-17.
set -e
get_page() { curl -LsS "$1"; }
get_href() { sed '/'"$1"'/!d;s,.*<a href=",,;s,".*,,;q'; }
get_rurl() { sed '/.*<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/I!d;s,,,;s,".*,,;q'; }
strip_pq() { sed 's,.*/,,;s,?.*,,'; }
download() { curl -R "$1" -o "$2"; }
echo "Finding download link for AOMEI Partition Assistant Standard:"
echo "- $HOMEPAGE"
CNETPAGE="$(get_page "$HOMEPAGE" | get_href "Local Download Freeware")"
echo "- $CNETPAGE"
CNETLINK="$(get_page "$CNETPAGE" | get_href "Download Now")"
echo "- $CNETLINK"
CNETDURL="$(get_page "$CNETLINK" | get_rurl)"
echo "- $CNETDURL"
FILENAME="$(echo "$CNETDURL" | strip_pq)"
echo "Downloading $FILENAME:"
download "$CNETDURL" "$FILENAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment