Ver a proveniência

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

tags/v0.4.5
Adrian Short há 6 anos
ascendente
cometimento
2778252c22
2 ficheiros alterados com 7 adições e 0 eliminações
  1. +3
    -0
      lib/uk_planning_scraper.rb
  2. +4
    -0
      lib/uk_planning_scraper/idox.rb

+ 3
- 0
lib/uk_planning_scraper.rb Ver ficheiro

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

+ 4
- 0
lib/uk_planning_scraper/idox.rb Ver ficheiro

@@ -51,6 +51,10 @@ module UKPlanningScraper
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
# Parse search results
items = page.search('li.searchresult')


Carregando…
Cancelar
Guardar