Skip to content

Instantly share code, notes, and snippets.

@nanpuyue
Last active March 21, 2018 06:40
Show Gist options
  • Save nanpuyue/625473fb186ca13da5e7aa94c7a8efd4 to your computer and use it in GitHub Desktop.
Save nanpuyue/625473fb186ca13da5e7aa94c7a8efd4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# file: dl_qt_example.sh
# date: 2018-03-21
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
URL="http://doc.qt.io/qt-5/qtwidgets-itemviews-frozencolumn-example.html"
BASE_URL=${URL%/*}
curl -so- "$URL"|\
sed -n '/^<p>Files\:/,/@@@/p'|\
grep -Po '(?<=href\=").*?(?=")'|\
while read line;do
data="$(curl -so- "$BASE_URL/$line")"
file="$(echo "$data"|grep -Po '(?<=@@@).*?(?=\s)')"
mkdir -p "${file%/*}" || true
echo "$data"|\
sed -n '/\$\$\$/,/@@@/p'|\
w3m -dump -T text/html|\
grep -v '^\['|\
cat > "$file"
echo "file: $file downloaded."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment