Quellcode durchsuchen

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

tags/v0.4.5
Adrian Short vor 6 Jahren
Ursprung
Commit
2778252c22
2 geänderte Dateien mit 7 neuen und 0 gelöschten Zeilen
  1. +3
    -0
      lib/uk_planning_scraper.rb
  2. +4
    -0
      lib/uk_planning_scraper/idox.rb

+ 3
- 0
lib/uk_planning_scraper.rb Datei anzeigen

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

+ 4
- 0
lib/uk_planning_scraper/idox.rb Datei anzeigen

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


Laden…
Abbrechen
Speichern