module Kijkwijzer
Constants
- POSSIBLE_RATINGS
- VERSION
Public Class Methods
get_content(search)
click to toggle source
# File lib/kijkwijzer.rb, line 26 def get_content(search) Nokogiri::HTML(open(search_url(search))) end
search(search, filter={})
click to toggle source
Search the Kijkwijzer
database
@return [Kijkwijzer::Result]
# File lib/kijkwijzer.rb, line 33 def search(search, filter={}) res = get_content(search) results = [] res.css('.content_hok .nieuwsitem').each do |result| r = Result.new() r.title = result.css('b').text production_type_match = result.text.match(/Productietype\:\s(.*)\.(\sProductie)/) production_year_match = result.text.match(/\sProductiejaar\:\s(\d\d\d\d)\.\s/) r.year = production_year_match[1].to_i if production_year_match r.production_type = production_type_match[1] if production_type_match r.ratings = result.css("img").collect{|a| a.attr("src").match(/\/upload\/pictogrammen\/\d*_\d*_(.*)\.png/)[1]} include_r = true filter.each do |key, value| include_r = (r.send(key) == value) end results << r if include_r end results end
search_url(search)
click to toggle source
# File lib/kijkwijzer.rb, line 23 def search_url(search) "http://www.kijkwijzer.nl/index.php?id=3__i&searchfor=#{url_encode(search)}&tab=KIJKWIJZER" end