Skip to content

Instantly share code, notes, and snippets.

@yesmeck
Last active December 17, 2015 14:59
Show Gist options
  • Save yesmeck/5628912 to your computer and use it in GitHub Desktop.
Save yesmeck/5628912 to your computer and use it in GitHub Desktop.
Stock
require 'open-uri'
require 'nokogiri'
code = 2904
doc = Nokogiri::HTML(open("http://just2.entrust.com.tw/z/zc/zca/zca_#{code}.djhtm"))
# 當前股價,既網頁中的收盤價
doc.css('table')[2].css('tr')[1].css('td').last.inner_text.to_f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment