Sfoglia il codice sorgente

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

tags/v0.4.5
Adrian Short 6 anni fa
parent
commit
2778252c22
2 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. +3
    -0
      lib/uk_planning_scraper.rb
  2. +4
    -0
      lib/uk_planning_scraper/idox.rb

+ 3
- 0
lib/uk_planning_scraper.rb Vedi File

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

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

@@ -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')


Caricamento…
Annulla
Salva