Skip to content

Instantly share code, notes, and snippets.

@Mr-Destructive
Created September 12, 2021 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr-Destructive/78f03a61792ac95fa0c882d84b106c85 to your computer and use it in GitHub Desktop.
Save Mr-Destructive/78f03a61792ac95fa0c882d84b106c85 to your computer and use it in GitHub Desktop.
#!/bin/bash
function strip_html(){
grep -oP '(?<=<span class="no-wrap" data-price-btc).*?(?=</span>)' $output >temp.txt
sed -i 's/[^>]*>//g' temp.txt >$output
sed -ni '1p' temp.txt >$output
cp temp.txt $output
rm temp.txt
}
function print(){
while read price
do
val=$price
done <$output
echo "The price of $coin is = $val"
}
read -p "enter the coin code : " coin
url='https://www.coingecko.com/en/coins/'$coin''
output=price.txt
touch $output temp.txt
curl -o $output $url
strip_html
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment