From 9229f1ff55066ff590d3b2f3c7dd0bf015835f50 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Tue, 25 Sep 2018 13:37:01 +0100 Subject: [PATCH] Add expected fields to search form if they're missing. Fix #6 This structure allows us to add other missing fields easily if necessary. --- lib/uk_planning_scraper/idox.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/uk_planning_scraper/idox.rb b/lib/uk_planning_scraper/idox.rb index 85d8048..f17d291 100644 --- a/lib/uk_planning_scraper/idox.rb +++ b/lib/uk_planning_scraper/idox.rb @@ -24,7 +24,12 @@ module UKPlanningScraper # Fill out and submit search form - # Some councils don't have the received from/to dates on their form, eg Newham + # Add expected fields to form if they're not already present so that searches using these terms work + %w{ + date(applicationReceivedStart) + date(applicationReceivedEnd) + }.each { |f| form.add_field!(f) unless form.has_field?(f) } + form.send(:"date(applicationReceivedStart)", params[:received_from].strftime("%d/%m/%Y")) if params[:received_from] form.send(:"date(applicationReceivedEnd)", params[:received_to].strftime("%d/%m/%Y")) if params[:received_to]