Ruby写的自动播报工行白银价格
老是盯着比较不爽~
查了下Ruby,写了个自动播报的小程序~
语音是自己用Mac录的,比较坑爹~
播放语音用的是win32/sound。。。
可能需要Gem一下~
gem install win32-sound --platform=ruby
require 'net/http'require 'win32/sound'include Win32loop do ICBC = Net::HTTP.get URI.parse('http://www.icbc.com.cn/ICBCDynamicSite/Charts/TimeLine.aspx?pWidth=1010&pHeight=600&dataType=0&dataId=903&picType=3')/<span id="cell1" style="color: Red">\s+(\d\.\d\d)/m =~ ICBCputsprice = Regexp.last_match(1)puts priceprefix = "E:\\Ariel-Share\"title = prefix + "title.wav"puts titleSound.play(title)price.each_char { |c|if c == '.' wav = prefix + "dot.wav"elsif wav = prefix + c + ".wav"endputs wavSound.play(wav)}sleep 60endecho "Silver"ruby E:\Ariel-Share\Silver.rbpause