Scrapes planning applications data for InLinkUK from BT kiosks.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
855 B

  1. require 'uk_planning_scraper'
  2. require 'scraperwiki'
  3. auths = UKPlanningScraper::Authority.all
  4. scrapes = [
  5. { validated_days: ENV['MORPH_DAYS'].to_i, keywords: 'inlink'},
  6. { validated_days: ENV['MORPH_DAYS'].to_i, keywords: 'bt phone kiosk'}
  7. ]
  8. auths.each_with_index do |auth, i|
  9. puts "#{i + 1} of #{auths.size}: #{auth.name}"
  10. scrapes.each_with_index do |scrape, j|
  11. puts "Scrape #{j + 1} of #{scrapes.size}: keywords: #{scrape[:keywords]}"
  12. begin
  13. apps = auth.scrape(scrape)
  14. apps.each do |app|
  15. unless app[:description].match(/chainlink/i) # Backend keyword search is weak
  16. ScraperWiki.save_sqlite([:authority_name, :council_reference], app, 'applications')
  17. end
  18. end
  19. puts "#{auth.name}: #{apps.size} application(s) saved."
  20. rescue StandardError => e
  21. puts "Error: #{e}"
  22. end
  23. end
  24. end