Skip to content
Snippets Groups Projects
Commit a2b34eaf authored by hqo1e21's avatar hqo1e21
Browse files

(Commit message) script file for running storing data

parent 9f08ab57
No related branches found
No related tags found
No related merge requests found
...@@ -2,20 +2,59 @@ ...@@ -2,20 +2,59 @@
curl https://www.kitco.com/charts/livegold.html > gold.html curl https://www.kitco.com/charts/livegold.html > gold.html
goldBID=$(cat gold.html | grep -E "sp-bid" | sed 's/[^.0-9]*//g') goldBID=$(cat gold.html | grep -E "sp-bid" | sed 's/[^.0-9]*//g')
goldASK=$(cat gold.html | grep -E "sp-ask" | sed 's/[^.0-9]*//g') goldASK=$(cat gold.html | grep -E "sp-ask" | sed 's/[^.0-9]*//g')
goldCHG=$(cat gold.html | grep -E "sp-chg-value" | sed 's/[^.0-9]*//g')
goldCHGpercent=$(cat gold.html | grep -E "sp-chg-percent" | sed 's/[^.0-9]*//g')
curl https://www.kitco.com/charts/livesilver.html > silver.html curl https://www.kitco.com/charts/livesilver.html > silver.html
silverBID=$(cat silver.html | grep -E "sp-bid" | sed 's/[^.0-9]*//g') silverBID=$(cat silver.html | grep -E "sp-bid" | sed 's/[^.0-9]*//g')
silverASK=$(cat silver.html | grep -E "sp-ask" | sed 's/[^.0-9]*//g') silverASK=$(cat silver.html | grep -E "sp-ask" | sed 's/[^.0-9]*//g')
silverCHG=$(cat silver.html | grep -E "sp-chg-value" | sed 's/[^.0-9]*//g')
silverCHGpercent=$(cat silver.html | grep -E "sp-chg-percent" | sed 's/[^.0-9]*//g')
curl https://www.kitco.com/charts/liveplatinum.html > platinum.html curl https://www.kitco.com/charts/liveplatinum.html > platinum.html
platinumBID=$(cat platinum.html | grep -E "sp-bid" | sed 's/[^.0-9]*//g') platinumBID=$(cat platinum.html | grep -E "sp-bid" | sed 's/[^.0-9]*//g')
platinumASK=$(cat platinum.html | grep -E "sp-ask" | sed 's/[^.0-9]*//g') platinumASK=$(cat platinum.html | grep -E "sp-ask" | sed 's/[^.0-9]*//g')
platinumCHG=$(cat platinum.html | grep -E "sp-chg-value" | sed 's/[^.0-9]*//g')
platinumCHGpercent=$(cat platinum.html | grep -E "sp-chg-percent" | sed 's/[^.0-9]*//g')
curl https://www.kitco.com/charts/livepalladium.html > palladium.html
palladiumBID=$(cat palladium.html | grep -E "sp-bid" | sed 's/[^.0-9]*//g')
palladiumASK=$(cat palladium.html | grep -E "sp-ask" | sed 's/[^.0-9]*//g')
palladiumCHG=$(cat palladium.html | grep -E "sp-chg-value" | sed 's/[^.0-9]*//g')
palladiumCHGpercent=$(cat palladium.html | grep -E "sp-chg-percent" | sed 's/[^.0-9]*//g')
date=$(date +%Y-%d-%m)
time=$(date "+%H:%M:%S %p")
#store to database
$(/opt/lampp/bin/mysql -u root -e"use cw2; insert into gold (goldBit,goldAsk,goldChg,goldChgPercent,dateTime) values ($goldBID,$goldASK,$goldCHG,$goldCHGpercent,default)")
$(/opt/lampp/bin/mysql -u root -e"use cw2; insert into silver (silverBit,silverAsk,silverChg,silverChgPercent,dateTime) values ($silverBID,$silverASK,$silverCHG,$silverCHGpercent,default)")
$(/opt/lampp/bin/mysql -u root -e"use cw2; insert into platinum (platinumBit,platinumAsk,platinumChg,platinumChgPercent,dateTime) values ($platinumBID,$platinumASK,$platinumCHG,$platinumCHGpercent,default)")
$(/opt/lampp/bin/mysql -u root -e"use cw2; insert into palladium (palladiumBit,palladiumAsk,palladiumChg,palladiumChgPercent,dateTime) values ($palladiumBID,$palladiumASK,$palladiumCHG,$palladiumCHGpercent,default)")
#store to txt file
echo -e "goldBid,$goldBID,goldAsk,$goldASK,goldChg,$goldCHG,goldChgPercent,$goldCHGpercent,$date $time\nsilverBid,$silverBID,silverAsk,$silverASK,silverChg,$silverCHG,silverChgPercent,$silverCHGpercent,$date $time\nplatinumBid,$platinumBID,platinumAsk,$platinumASK,platinumChg,$platinumCHG,platinumChgPercent,$platinumCHGpercent,$date $time\npalladiumBid,$palladiumBID,palladiumAsk,$palladiumASK,palladiumChg,$palladiumCHG,palladiumChgPercent,$palladiumCHGpercent,$date $time\n" >> data.txt
#store to csv file
gold=$(cat data.txt | grep -E 'gold' | cut -d ',' -f2,4,6,8,9)
silver=$(cat data.txt | grep -E 'silver' | cut -d ',' -f2,4,6,8,9)
platinum=$(cat data.txt | grep -E 'platinum' | cut -d ',' -f2,4,6,8,9)
palladium=$(cat data.txt | grep -E 'palladium' | cut -d ',' -f2,4,6,8,9)
echo "$gold" > gold.csv
echo "$silver" > silver.csv
echo "$platinum" > platinum.csv
echo "$palladium" > palladium.csv
date=$(date +%d-%m-%Y)
time=$(date "+%H-%M %p")
echo -e "gold Bid: $goldBID, silver Bid: $silverBID, platinum Bid: $platinumBID\ngold Ask: $goldASK, silver Ask: $silverASK, platinum Ask: $platinumASK, $date $time" >> data.txt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment