11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/movie_show_times/crawler.rb', line 11
def initialize(options = {})
raise MissingLocationArgument unless options[:location]
language = options[:language] || 'en'
days_ahead = options[:days_ahead] || 0
raise WrongDaysAheadArgument unless days_ahead.kind_of? Integer and 0 >= days_ahead
@parser = MovieShowTimes::Parser.new(language)
search_url = "http://www.google.com/movies?hl=#{language}" \
"&near=#{CGI.escape(options[:location])}&date=#{days_ahead}"
@agent = Mechanize.new
page = @agent.get(search_url)
crawl_result_pages(page)
end
|