Created
September 24, 2018 06:51
-
-
Save willinspire/5c392dd9ea5994a2a77254f265434e2f to your computer and use it in GitHub Desktop.
Mirror the table of cryptocurrency arbitrage data provided by Cryptopia exchange (automate running this script via cron to keep it updated)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Cryptocurrency Arbitrage Page Builder | |
# Data provided by Cryptopia.co.nz | |
# Assembled by h8rt3rmin8r on 20180924 | |
# | |
# NOTE: This bash script requires prior installation of Apache or some other web host | |
# software and it requires write-access to /var/www/html/index.html | |
# Set up the output location in a public-facing HTML page | |
rm /var/www/html/index.html &>/dev/null | |
touch /var/www/html/index.html | |
# Fetch the latest data | |
curl -s 'https://www.cryptopia.co.nz/Arbitrage/GetArbitrageSummary?currencyId=1&_=1537764644870' \ | |
-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0' \ | |
-H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' \ | |
--compressed \ | |
-H 'Referer: https://www.cryptopia.co.nz/' \ | |
-H 'X-Requested-With: XMLHttpRequest' \ | |
-H 'Connection: keep-alive' \ | |
-H 'TE: Trailers' >> temp.html | |
# Remove junk lines | |
sed -i -e 1,24d temp.html | |
# Remove image resources | |
while read -r line | |
do [[ ! $line =~ "<img " ]] && echo "$line" | |
done <temp.html > o | |
mv o temp.html | |
# Compile additional style and web parts | |
sleep 0.8; curl -s 'https://pastebin.com/raw/5SXVnKhu' | dos2unix >> temp.html | |
sleep 0.8; curl -s 'https://pastebin.com/raw/U3fEdJdJ' | dos2unix >> /var/www/html/index.html | |
sleep 0.8; cat temp.html >> /var/www/html/index.html | |
# Remove the temporary file and view the output in Firefox browser | |
rm temp.html | |
firefox /var/www/html/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment