class PhishtankScraper

Director interface for scraping

Attributes

range[R]
site[R]

Public Class Methods

new(url="http://phishtank.com") click to toggle source
# File lib/phishtank_scraper.rb, line 8
def initialize(url="http://phishtank.com")
  @site = Site.new(url)
  @range = (0..0)
end

Public Instance Methods

id_scrape(since, options={}) click to toggle source

returns an array of detections from id to last submitted id options: active: “All”, “n”, “y”, “u” valid: “All”, “n”, “y”, “u”

# File lib/phishtank_scraper.rb, line 27
def id_scrape(since, options={})
  since = since.to_i
  page_at = PhishingSet.new(@site.home).page_at_id(since)

  phset = (0..page_at).map do |page_index|
    PhishingSet.new(@site.build_path(page_index, options)).all
  end.flatten
  
  phset.delete_if {|ph| ph[:id].to_i < since}
end
page_scrape(range=@range, options={}) click to toggle source

returns an array of detections in the pages range options: active: “All”, “n”, “y”, “u” valid: “All”, “n”, “y”, “u”

# File lib/phishtank_scraper.rb, line 17
def page_scrape(range=@range, options={})
  build_range(range).map do |page_index|
    PhishingSet.new(@site.build_path(page_index, options)).all
  end.flatten
end

Private Instance Methods

build_range(value) click to toggle source
# File lib/phishtank_scraper.rb, line 39
def build_range(value)
  @range = value.class.eql?(Range) ? value : (value..value)
end