Class: Sc::UriSelector

Inherits:
Selector show all
Defined in:
lib/scrappy/extractor/selectors/uri.rb

Instance Method Summary collapse

Methods inherited from Selector

#select

Methods included from Scrappy::Formats

#format

Instance Method Details

#filter(doc) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/scrappy/extractor/selectors/uri.rb', line 3

def filter doc
  # Check if the UriSelector has this URI as value (without params: ?param1=value1&param2=value2)
  if rdf::value.include?(doc[:uri].match(/\A([^\?]*)(\?.*\Z)?/).captures.first)
    [ { :uri=>doc[:uri], :content=>doc[:content], :value=>format(doc[:value], sc::format, doc[:uri]) } ]
  else
    []
  end
end