Skip to content

Instantly share code, notes, and snippets.

@rreimann
Created May 15, 2018 10:14
Show Gist options
  • Save rreimann/5bfee664f92ad750ff8c22d3332b1a76 to your computer and use it in GitHub Desktop.
Save rreimann/5bfee664f92ad750ff8c22d3332b1a76 to your computer and use it in GitHub Desktop.
lookup historic etf/stock prices via onvista
#!/bin/sh
if [ $# -ne 1 ] ; then
echo "lookup historic etf/stock prices via onvista"
echo "Usage: $0 {ISIN}"
exit -1
fi
html=$(curl -s -L https://www.onvista.de/$1)
name=$(echo $html | pup 'title text{}' | sort -u)
onvistaId=$(echo $html | pup 'div.item[data-contributor="Xetra"] attr{data-value}' | sort -u)
if [ -n "$onvistaId" ]; then
type="fonds"
else
tmpId=$(echo $html | pup 'a[href^="?notation"]:contains("Xetra") attr{href}' | sort -u)
onvistaId=${tmpId#"?notation="}
type="aktien"
fi
echo "$name"
echo "http://www.onvista.de/${type}/kurshistorie.html?ID_NOTATION=${onvistaId}&RANGE=120M"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment