diff --git a/README.md b/README.md index 9b83083..c99ac21 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ keywords("hip gable") applicant_name("Mr and Mrs Smith") # Currently Idox only application_type("Householder") # Currently Idox only development_type("") # Currently Idox only +case_officer_code("100000") # Northgate only scrape # runs the scraper ``` diff --git a/lib/uk_planning_scraper/authority.rb b/lib/uk_planning_scraper/authority.rb index 621e7a3..9c2c14b 100644 --- a/lib/uk_planning_scraper/authority.rb +++ b/lib/uk_planning_scraper/authority.rb @@ -70,7 +70,7 @@ module UKPlanningScraper def system if @url.match(/search\.do\?action=advanced/i) 'idox' - elsif @url.match(/generalsearch\.aspx/i) + elsif @url.match(/\.aspx/i) 'northgate' elsif @url.match(/ocellaweb/i) 'ocellaweb' diff --git a/lib/uk_planning_scraper/authority_scrape_params.rb b/lib/uk_planning_scraper/authority_scrape_params.rb index 819c6e2..13d3b63 100644 --- a/lib/uk_planning_scraper/authority_scrape_params.rb +++ b/lib/uk_planning_scraper/authority_scrape_params.rb @@ -62,6 +62,17 @@ module UKPlanningScraper self end + def case_officer_code(s) + unless system == 'northgate' + raise NoMethodError.new("case_officer_code is only implemented for Northgate. \ + This authority (#{@name}) is #{system.capitalize}.") + end + + check_class(s, String) + @scrape_params[:case_officer_code] = s.strip + self + end + def application_type(s) unless system == 'idox' raise NoMethodError.new("application_type is only implemented for \ diff --git a/lib/uk_planning_scraper/northgate.rb b/lib/uk_planning_scraper/northgate.rb index 252834b..e61c3d7 100644 --- a/lib/uk_planning_scraper/northgate.rb +++ b/lib/uk_planning_scraper/northgate.rb @@ -24,6 +24,7 @@ module UKPlanningScraper 'csbtnSearch' => 'Search' # required } + # Keywords form_vars['txtProposal'] = params[:keywords] # Date received from and to @@ -50,6 +51,12 @@ module UKPlanningScraper form_vars['dateEnd'] = params[:decided_to].to_s if params[:decided_to] # YYYY-MM-DD end + # Case officer code + if params[:case_officer_code] + form_vars['cboCaseOfficerCode'] = params[:case_officer_code] + @url.sub!('GeneralSearch.aspx', 'CaseOfficerWorkloadSearch.aspx') + end + logger.info "Form variables: #{form_vars.to_s}" headers = {