Skip to content

Instantly share code, notes, and snippets.

@jyootai
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jyootai/5564f1532169c39b4a2a to your computer and use it in GitHub Desktop.
Save jyootai/5564f1532169c39b4a2a to your computer and use it in GitHub Desktop.
A script to help you view events
# encoding: utf-8
require 'open-uri'
require 'nokogiri'
puts"======================"
puts "请输入要查询的日期并按回车结束:"
date = gets()
init_uri = "http://www.zhibo8.cc/"
doc = Nokogiri::HTML(open(init_uri))
today=Time.now.day
id = case date.to_i
when today then 2
when today+1 then 3
when today+2 then 4
when today+3 then 5
when today+4 then 6
when today+5 then 7
when today+6 then 8
when today+7 then 9
when today+8 then 10
when today+9 then 11
when today+10 then 12
when today+11 then 13
when today+12 then 14
when today+13 then 15
when today+14 then 16
when today+15 then 17
else 0
end
if id == 0
puts "对不起,暂无赛事数据提供"
else
puts doc.xpath("//div[@class='box']")[id].text
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment