Re: [問題] 要做個自動抓基金淨值功能
※ 引述《Storm (風)》之銘言:
> ※ 引述《theater.bbs@ptt.cc (我在O2的年紀逐漸升高了)》之銘言:
> > 如題
> > http://fund.cnyes.com/Detail/historicalNav/B08,020.html
> > 例如上面連結
> > 想打開程式後就自動淨值更新,然後存在一個txt檔
> > 我才不用每次都手動更新
> > 然後我再用程式自己分析txt裡面的淨值,得到我想要的計算
> > 更新的功能該如何實現呢?
> wget -O - -q http://fund.cnyes.com/Detail/historicalNav/B08,020.html \
> | grep '個別基金:start' \
> | sed -e 's|.*<td class="pe r">\([0-9]\+\.[0-9]\{2\}\)</td>.*|\1|g' > a.txt
> 產生的 a.txt 內容類似這樣:
> 1.77
還可以用 gawk 合併 grep 和 sed 的部分:
wget -O - http://fund.cnyes.com/Detail/historicalNav/B08,020.html \
|awk '/個別基金:start/
{print gensub(/.*"pe r">([0-9]+\.[0-9][0-9])<\/td>.*/,"\\1","") > "a.txt"}'
或
wget -O - http://fund.cnyes.com/Detail/historicalNav/B08,020.html \
|awk '/個別基金:start/
{print gensub(/.*"pe r">([0-9]+\.[0-9][0-9])<\/td>.*/,"\\1","")}' > a.txt
--
※ Origin: SayYA 資訊站 <bbs.sayya.org>
◆ From: c-76-111-34-186.hsd1.ga.comcast.net
討論串 (同標題文章)
Programming 近期熱門文章
PTT數位生活區 即時熱門文章