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.

31 lines
982 B

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