1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
| #!/bin/sh
#
# 抓取 wap.eastmoney.com 原油指数
#最新价
latestprice="";
#涨跌值
Pricevalue="";
#涨跌幅
risingAndfalling="";
#今开盘
openingQuotation="";
#最高价
ceilingprice="";
#最低价
bottomprice="";
#昨收盘
closingQuotation="";
#交易时间
exchangehour="";
# 分时图URL
timeLine="";
# K线图
KChart="";
#获得html
wget -O conc.html -q --user-agent="Mobile Safari/534.30" --no-cookies \
--referer="http://wap.eastmoney.com/Futures.aspx" \
http://wap.eastmoney.com/FuturesInfo.aspx?c=CONC
# 最新价:.{7}(.{4,5})
latestprice="`grep -o '最新价:.\{7\}\(.\{4,5\}\)' conc.html | awk 'gsub(/<[^>]*>/,"")'`"
#gsub(r,s,t) 在字符串t中,用s替换和正则r匹配所有字符串 返回替换的个数。如果没有给出t,缺省为$0
# 涨跌值:.{45}(.{3,5}[0-9])
Pricevalue="`grep -o '涨跌值:.\{45\}\(.\{3,5\}[0-9]\)' conc.html | awk 'gsub(/<[^>]*>/,"")'`"
# 涨跌幅:.{45}(.{4,5}%)
risingAndfalling="`grep -o '涨跌幅:.\{45\}\(.\{4,5\}%\)' conc.html | awk 'gsub(/<[^>]*>/,"")'`"
# 今开盘:.{7}(.{3,5}[0-9])
openingQuotation="`grep -o '今开盘:.\{7\}\(.\{3,5\}[0-9]\)' conc.html | awk 'gsub(/<[^>]*>/,"")'`"
# 最高价:.{7}(.{4,5}[0-9])
ceilingprice="`grep -o '最高价:.\{7\}\(.\{4,5\}[0-9]\)' conc.html | awk 'gsub(/<[^>]*>/,"")'`"
# 最低价:.{7}(.{4,5}[0-9])
bottomprice="`grep -o '最低价:.\{7\}\(.\{4,5\}[0-9]\)' conc.html | awk 'gsub(/<[^>]*>/,"")'`"
# 昨收盘:.{7}(.{4,5}[0-9])
closingQuotation="`grep -o '昨收盘:.\{7\}\(.\{4,5\}[0-9]\)' conc.html | awk 'gsub(/<[^>]*>/,"")'`"
# 交易时间:.{7}(.{19})
exchangehour="`grep -o '交易时间:.\{7\}\(.\{19\}\)' conc.html | awk 'gsub(/<[^>]*>/,"")'`"
# 分时图.*(ht.*)K
timeLine="`grep -o '分时图.*\(ht.*\)K' conc.html|\
grep -o '\(http.*0\)'|awk 'gsub(/amp;/,"")'`"
#获得分时图
wget -O timeline.png -q --user-agent="Mobile Safari/534.30" --no-cookies \
--referer="http://wap.eastmoney.com/Futures.aspx" $timeLine
#获得k线图 K线图.*(ht.*C0)
KChart="`grep -o 'K线图.*\(ht.*C0\)' conc.html|\
grep -o '\(http.*0\)'|awk 'gsub(/amp;/,"")'`";
wget -O KChart.png -q --user-agent="Mobile Safari/534.30" --no-cookies \
--referer="http://wap.eastmoney.com/Futures.aspx" $KChart
echo $latestprice
echo $Pricevalue
echo $risingAndfalling
echo $openingQuotation
echo $ceilingprice
echo $bottomprice
echo $closingQuotation
echo $exchangehour
#echo $timeLine
#echo $KChart
tPicPath="`pwd`""/timeline.png";
KPicPath="`pwd`""/KChart.png";
notify-send -t 20000 -i $tPicPath "$latestprice $Pricevalue" " $risingAndfalling $openingQuotation \
$ceilingpric $bottomprice $closingQuotation $exchangehour"
|