how to grep data from site
#!/bin/bash
wget -q -O hkindex.html http://www.aastocks.com/EN/market/HKIndex.aspx?Index=VHSI
rm -f cq
cat hkindex.html | grep -A 23 '' > indextable
#cat indextable | grep '>VHSI<' > vhsivalue
cat indextable | grep '>HSI<' | awk -F '[<|>]' '{print $3 "\t" $7}' > hsis
cat indextable | grep '>HS Red-chip<' | awk -F '[<|>]' '{print $3 "\t" $7}' >> hsis
cat indextable | grep '>HSCEI<' | awk -F '[<|>]' '{print $3 "\t" $7}' >> hsis
cat indextable | grep '>GEM<' | awk -F '[<|>]' '{print $3 "\t" $7}' >> hsis
cat indextable | grep '>HSI FIN<' | awk -F '[<|>]' '{print $3 "\t" $7}' >> hsis
cat indextable | grep '>HSI UTI<' | awk -F '[<|>]' '{print $3 "\t" $7}' >> hsis
cat indextable | grep '>HSI PROP<' | awk -F '[<|>]' '{print $3 "\t" $7}' >> hsis
cat indextable | grep '>HSI COM&IND<' | awk -F '[<|>]' '{print $3 "\t" $7}' >> hsis
cat indextable | grep '>VHSI<' | awk -F '[<|>]' '{print $3 "\t" $7}' >> hsis
cat hsis
3.8
10
#!/bin/bash
#filename: get_quote.sh
#author: Chao Wang
rm -f $1quote.html
wget -q -O $1quote.html http://www.aastocks.com/en/stock/DetailQuote.aspx?symbol=$1
cat $1quote.html | grep '' -B 1 | grep '[0-9].[0-9]' | awk -F ' - ' '{print "StockCode: " $1}'
cat $1quote.html | grep '>Last]' '{print "LastPrice: " $7}'
cat $1quote.html | grep '>Lot Size' -A 1 | grep '[0-9].[0-9]' | awk -F '[<|>]' '{print "LotSize: " $3}'
cat $1quote.html | grep '>Spread' -A 1 | grep '[0-9]/[0-9]' | awk -F '[<|>]' '{print "Spread: " $3}'
cat $1quote.html | grep '>P/E Ratio' -A 1 | grep '[0-9].[0-9]' | awk -F '[<|>]' '{print "PERatio: " $3}'
cat $1quote.html | grep '>EPS' -A 1 | grep '[0-9].[0-9]' | awk -F '[<|>]' '{print "EPS: " $3}'
cat $1quote.html | grep '>Last Update:<' -A 1 | grep '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' | awk -F '[<|>]' '{print "LastUpdateTime: " $3}'
rm -f $1quote.html
Thank you!
10
0
Are there any code examples left?
New code examples in category Shell/Bash
-
Shell/Bash 2022-03-27 22:30:33 wise highlight ubuntu
-
Shell/Bash 2022-03-27 22:25:19 how to send a pull request in git
-
Shell/Bash 2022-03-27 21:55:06 how to open terminal in sublime text ubuntu
-
Shell/Bash 2022-03-27 21:25:19 how to switch branch
-
Shell/Bash 2022-03-27 21:20:25 python
-
Shell/Bash 2022-03-27 21:20:04 set user as admin gitlab
-
Shell/Bash 2022-03-27 21:10:09 apache2 mod_jk proxy to tomcat connector
-
Shell/Bash 2022-03-27 20:35:12 chown
-
Shell/Bash 2022-03-27 20:15:08 awk last match