Class: GoogleMovies47::Crawler
- Inherits:
-
Object
- Object
- GoogleMovies47::Crawler
- Defined in:
- lib/google_movies47/crawler.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Crawler
constructor
A new instance of Crawler.
- #movies ⇒ Object
- #theaters ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Crawler
Returns a new instance of Crawler.
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( = {}) raise MissingLocationArgument unless [:city] and [:state] language = [:language] || 'en' days_ahead = [: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=#{[:city]}%2C+#{[:state]}&date=#{days_ahead}" @agent = Mechanize.new page = @agent.get(search_url) crawl_result_pages(page) end |
Instance Method Details
#movies ⇒ Object
32 33 34 |
# File 'lib/google_movies47/crawler.rb', line 32 def movies @parser.movies end |
#theaters ⇒ Object
36 37 38 |
# File 'lib/google_movies47/crawler.rb', line 36 def theaters @parser.theaters end |