From 8fdb3a7f87290dc32d49996ce456604361d72de0 Mon Sep 17 00:00:00 2001 From: MichaelBone <37421067+MichaelBone@users.noreply.github.com> Date: Thu, 16 Aug 2018 09:44:07 +0930 Subject: [PATCH] Added safety count. --- scraper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scraper.rb b/scraper.rb index 798653b..a6c49d2 100644 --- a/scraper.rb +++ b/scraper.rb @@ -73,6 +73,7 @@ # p summary_page.title.strip p "Paging" +count = 0 das_data = [] while summary_page table = summary_page.root.at_css('.ContentPanel') @@ -88,6 +89,11 @@ next_page_path = next_page_img['onclick'].split(',').find { |e| e =~ /.*PageNumber=\d+.*/ }.gsub('"', '').strip p "Found another page: " + next_page_path summary_page = agent.get "#{base_url}#{next_page_path}" + count = count + 1 + if count > 2 + p "Stopping paging after " + count + "pages." + break + end end end