Browse Source

Scrape validated apps as well as decided ones

pull/1/head
Adrian Short 6 years ago
parent
commit
7bd4cd303e
1 changed files with 14 additions and 7 deletions
  1. +14
    -7
      scraper.rb

+ 14
- 7
scraper.rb View File

@@ -3,13 +3,20 @@ require 'scraperwiki'

auths = UKPlanningScraper::Authority.tagged('london')

scrapes = [
{ validated_days: ENV['MORPH_DAYS'].to_i },
{ decided_days: ENV['MORPH_DAYS'].to_i }
]

auths.each_with_index do |auth, i|
begin
puts "#{i + 1} of #{auths.size}: Scraping #{auth.name}"
apps = auth.scrape({ decided_days: ENV['MORPH_DAYS'].to_i })
ScraperWiki.save_sqlite([:authority_name, :council_reference], apps)
puts "#{auth.name}: #{apps.size} application(s) saved."
rescue StandardError => e
puts e
scrapes.each_with_index do |scrape, j|
puts "Authority #{i + 1} of #{auths.size}: Scrape #{j + 1} of #{scrapes.size} for #{auth.name}."
begin
apps = auth.scrape(scrape)
ScraperWiki.save_sqlite([:authority_name, :council_reference], apps)
puts "#{auth.name}: #{apps.size} application(s) saved."
rescue StandardError => e
puts e
end
end
end

Loading…
Cancel
Save