Browse Source

Raise exception if search gives "too many results" error. Fix #14

tags/v0.4.5
Adrian Short 6 years ago
parent
commit
2778252c22
2 changed files with 7 additions and 0 deletions
  1. +3
    -0
      lib/uk_planning_scraper.rb
  2. +4
    -0
      lib/uk_planning_scraper/idox.rb

+ 3
- 0
lib/uk_planning_scraper.rb View File

@@ -10,4 +10,7 @@ module UKPlanningScraper
class AuthorityNotFound < StandardError class AuthorityNotFound < StandardError
end end
class TooManySearchResults < StandardError
end
end end

+ 4
- 0
lib/uk_planning_scraper/idox.rb View File

@@ -51,6 +51,10 @@ module UKPlanningScraper
page = form.submit page = form.submit


if page.search('.errors').inner_text.match(/Too many results found/i)
raise TooManySearchResults.new("Scrape in smaller chunks. Use shorter date ranges and/or more search parameters.")
end
loop do loop do
# Parse search results # Parse search results
items = page.search('li.searchresult') items = page.search('li.searchresult')


Loading…
Cancel
Save