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
Awgiedawgie 440215 points

                                    #!/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 &quot;StockCode: &quot; $1}'
cat $1quote.html | grep '&gt;Last]' '{print &quot;LastPrice: &quot; $7}'
cat $1quote.html | grep '&gt;Lot Size' -A 1 | grep '[0-9].[0-9]' | awk -F '[&lt;|&gt;]' '{print &quot;LotSize: &quot; $3}'
cat $1quote.html | grep '&gt;Spread' -A 1 | grep '[0-9]/[0-9]' | awk -F '[&lt;|&gt;]' '{print &quot;Spread: &quot; $3}'
cat $1quote.html | grep '&gt;P/E Ratio' -A 1 | grep '[0-9].[0-9]' | awk -F '[&lt;|&gt;]' '{print &quot;PERatio: &quot; $3}'
cat $1quote.html | grep '&gt;EPS' -A 1 | grep '[0-9].[0-9]' | awk -F '[&lt;|&gt;]' '{print &quot;EPS: &quot; $3}'
cat $1quote.html | grep '&gt;Last Update:&lt;' -A 1 | grep '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' | awk -F '[&lt;|&gt;]' '{print &quot;LastUpdateTime: &quot; $3}'
rm -f $1quote.html

3.8 (10 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source