Skip to content

Instantly share code, notes, and snippets.

@crabtw
Created February 6, 2012 07:48
Show Gist options
  • Select an option

  • Save crabtw/1750528 to your computer and use it in GitHub Desktop.

Select an option

Save crabtw/1750528 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require 'open-uri'
require 'pdf/reader'
io = open('http://www.nctu.edu.tw/campus/bulletin/Calendar/calendar2011.pdf')
reader = PDF::Reader.new(io)
sems = reader.pages.map do |page|
sem = page.text.scan(
/本學期自(\d+)年(\d+)月(\d+)日.+至(\d+)年(\d+)月(\d+)日/
)[0]
if sem
sem.map(&:to_i)
end
end
fall, spring = sems.select {|s| s}
p fall
p spring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment