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