Scrapes planning applications data for InLinkUK from BT kiosks.
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

28 righe
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