|
|
@@ -10,14 +10,40 @@ module UKPlanningScraper |
|
|
|
} |
|
|
|
options = default_options.merge(options) # The user-supplied options override the defaults |
|
|
|
|
|
|
|
# Validated within the last n days |
|
|
|
# Assumes that every scraper/system can do a date range search |
|
|
|
if params[:validated_days] |
|
|
|
params[:validated_to] = Date.today |
|
|
|
params[:validated_from] = Date.today - (params[:validated_days] - 1) |
|
|
|
params[:validated_days].delete |
|
|
|
end |
|
|
|
|
|
|
|
# Received within the last n days |
|
|
|
# Assumes that every scraper/system can do a date range search |
|
|
|
if params[:received_days] |
|
|
|
params[:received_to] = Date.today |
|
|
|
params[:received_from] = Date.today - (params[:received_days] - 1) |
|
|
|
params[:received_days].delete |
|
|
|
end |
|
|
|
|
|
|
|
# Decided within the last n days |
|
|
|
# Assumes that every scraper/system can do a date range search |
|
|
|
if params[:decided_days] |
|
|
|
params[:decided_to] = Date.today |
|
|
|
params[:decided_from] = Date.today - (params[:decided_days] - 1) |
|
|
|
params[:decided_days].delete |
|
|
|
end |
|
|
|
|
|
|
|
# Select which scraper to use based on the URL |
|
|
|
if search_url.match(/search\.do\?action=advanced/i) |
|
|
|
return self.scrape_idox(search_url, params, options) |
|
|
|
apps = self.scrape_idox(search_url, params, options) |
|
|
|
elsif search_url.match(/generalsearch\.aspx/i) |
|
|
|
return self.scrape_northgate(search_url, params, options) |
|
|
|
apps = self.scrape_northgate(search_url, params, options) |
|
|
|
else |
|
|
|
# Not supported |
|
|
|
raise "Planning system not supported for URL: #{search_url}" |
|
|
|
end |
|
|
|
|
|
|
|
apps # Single point of successful exit |
|
|
|
end |
|
|
|
end |