汇率 http://stackoverflow.com/questions/10040954/alternative-to-google-finance-api http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote http://blog.programmableweb.com/2008/04/24/25-finance-apis/ 上证,深证等 http://www.cnblogs.com/kingwolfofsky/archive/2011/08/14/2138081.html 代码共享(ruby) # coding: utf-8 require 'nokogiri' require 'csv' require 'net/http' FXs = [ 'JPY', 'AUD', 'XAU', 'EUR', 'GBP' ] GUs = [ 'sh000001', 'sz002344', 'sz300159', 'sh600717', 'sh600332' ] results = [] http = Net::HTTP.new("hq.sinajs.cn") GUs.each do |gu| response,body = http.get("/list=#{gu}") doc = response.body re = doc.scan(/.*\"(.*)\";/) array = CSV.parse(re[0][0]) results << "#{gu}: #{array[0][3]}" end http2 = Net::HTTP.new('finance.yahoo.com') response = http2.get('/webservice/v1/symbols/allcurrencies/quote') xml = response.body doc = Nokogiri::Slop(xml) doc.list.resources.resource.each do |e| FXs.each do |f| fx = f + "=X" if e.xpath('field[@name="symbol"]').text() == fx price = e.xpath('field[@name="price"]').text() p = fx == 'JPY=X' ? price : 1 / price.to_f results << format("%s: %.4f\n", f, p.to_f) end end end results.each {|e| puts e} 我现在关注的股票都给你了 (^^)
http://stackoverflow.com/questions/3139879/how-do-i-get-currency-exchange-rates-via-an-api-such-as-google-finance
汇率
上证,深证等
代码共享(ruby)