瀏覽代碼

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

tags/v0.4.5
Adrian Short 6 年之前
父節點
當前提交
2778252c22
共有 2 個檔案被更改,包括 7 行新增0 行删除
  1. +3
    -0
      lib/uk_planning_scraper.rb
  2. +4
    -0
      lib/uk_planning_scraper/idox.rb

+ 3
- 0
lib/uk_planning_scraper.rb 查看文件

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

+ 4
- 0
lib/uk_planning_scraper/idox.rb 查看文件

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


Loading…
取消
儲存