A Ruby gem to get planning applications data from UK council websites.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
před 6 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. # UK Planning Scraper
  2. **PRE-ALPHA: Only works with Idox and Northgate sites and spews a lot of stuff
  3. to STDOUT. Not for production use.**
  4. This gem scrapes planning applications data from UK local planning authority
  5. websites, eg Westminster City Council. Data is returned as an array of hashes,
  6. one hash for each planning application.
  7. This scraper gem doesn't use a database. Storing the output is up to you. It's
  8. just a convenient way to get the data.
  9. Currently this only works for Idox and Northgate sites. The ultimate aim is to
  10. provide a consistent interface in a single gem for all variants of all planning
  11. systems: Idox Public Access, Northgate Planning Explorer, OcellaWeb, Agile
  12. Planning and all the one-off systems.
  13. This project is not affiliated with any organisation.
  14. ## Installation
  15. Add this line to your application's Gemfile:
  16. ```ruby
  17. gem 'uk_planning_scraper'
  18. ```
  19. And then execute:
  20. $ bundle install
  21. Or install it directly:
  22. $ gem install uk_planning_scraper
  23. ## Usage
  24. ### First, require your stuff
  25. ```ruby
  26. require 'uk_planning_scraper'
  27. require 'pp'
  28. ```
  29. ### Scrape from a council
  30. Applications in Westminster decided in the last seven days:
  31. ```ruby
  32. pp UKPlanningScraper::Authority.named('Westminster').decided_days(7).scrape
  33. ```
  34. ### Scrape from a bunch of councils
  35. Scrape the last week's planning decisions across the whole of
  36. London (actually 23 of the 35 authorities right now):
  37. ```ruby
  38. authorities = UKPlanningScraper::Authority.tagged('london')
  39. authorities.each do |authority|
  40. applications = authority.decided_days(7).scrape
  41. pp applications
  42. # You'll probably want to save `applications` to your database here
  43. end
  44. ```
  45. ### Satisfy your niche interests
  46. Launderette applications validated in the last seven days in Scotland:
  47. ```ruby
  48. authorities = UKPlanningScraper::Authority.tagged('scotland')
  49. authorities.each do |authority|
  50. applications = authority.validated_days(7).keywords('launderette').scrape
  51. pp applications # You'll probably want to save `apps` to your database here
  52. end
  53. ```
  54. ### More scrape parameter methods
  55. Chain as many scrape parameter methods on a `UKPlanningScraper::Authority`
  56. object as you like, making sure that `scrape` comes last.
  57. ```ruby
  58. received_from(Date.parse("1 Jan 2016"))
  59. received_to(Date.parse("31 Dec 2016"))
  60. # Received in the last n days (including today)
  61. # Use instead of received_to, received_from
  62. received_days(7)
  63. validated_to(Date.today)
  64. validated_from(Date.today - 30)
  65. validated_days(7) # instead of validated_to, validated_from
  66. decided_to(Date.today)
  67. decided_from(Date.today - 30)
  68. decided_days(7) # instead of decided_to, decided_from
  69. # Check that the systems you're scraping return the
  70. # results you expect for multiple keywords (AND or OR?)
  71. keywords("hip gable")
  72. applicant_name("Mr and Mrs Smith") # Currently Idox only
  73. application_type("Householder") # Currently Idox only
  74. development_type("") # Currently Idox only
  75. case_officer_code("100000") # Northgate only
  76. scrape # runs the scraper
  77. ```
  78. ### Save to a SQLite database
  79. This gem has no interest whatsoever in persistence. What you do with the data it
  80. outputs is up to you: relational databases, document stores, VHS and clay
  81. tablets are all blissfully none of its business. But using the
  82. [ScraperWiki](https://github.com/openaustralia/scraperwiki-ruby) gem is a really
  83. easy way to store your data:
  84. ```ruby
  85. require 'scraperwiki' # Must be installed, of course
  86. ScraperWiki.save_sqlite([:authority_name, :council_reference], applications)
  87. ```
  88. That `applications` param can be a hash or an array of hashes, which is what
  89. gets returned by our `Authority.scrape`.
  90. ### Find authorities by tag
  91. Tags are always lowercase and one word.
  92. ```ruby
  93. london_auths = UKPlanningScraper::Authority.tagged('london')
  94. ```
  95. We've got tags for areas:
  96. - london
  97. - innerlondon
  98. - outerlondon
  99. - northlondon
  100. - southlondon
  101. - greatermanchester
  102. - surrey
  103. - wales
  104. We also automatically add tags for software systems:
  105. - idox
  106. - northgate
  107. - ocellaweb
  108. - agileplanning
  109. - unknownsystem -- for when we can't identify the system
  110. and whatever you'd like to add that would be useful to others.
  111. ### WTF is up with London?
  112. London has got 32 London Boroughs, tagged `londonboroughs`. These are the
  113. councils under the authority of the Mayor of London and the Greater London
  114. Authority.
  115. It has 33 councils: the London Boroughs plus the City of London (named `City of
  116. London`). We don't currently have a tag for this, but if you want to add
  117. `londoncouncils` please go ahead.
  118. And it's got 35 local planning authorities: the 33 councils plus the two
  119. `londondevelopmentcorporations`, named `London Legacy Development Corporation`
  120. and `Old Oak and Park Royal Development Corporation`. The tag `london` covers
  121. all (and only) the 35 local planning authorities in London.
  122. ```ruby
  123. UKPlanningScraper::Authority.tagged('londonboroughs').size
  124. # => 32
  125. UKPlanningScraper::Authority.tagged('londondevelopmentcorporations').size
  126. # => 2
  127. UKPlanningScraper::Authority.tagged('london').size
  128. # => 35
  129. ```
  130. ### More fun with Authority tags
  131. ```ruby
  132. UKPlanningScraper::Authority.named('Merton').tags
  133. # => ["england", "london", "londonboroughs", "northgate", "outerlondon", "southlondon"]
  134. UKPlanningScraper::Authority.not_tagged('london')
  135. # => [...]
  136. UKPlanningScraper::Authority.named('Islington').tagged?('southlondon')
  137. # => false
  138. ```
  139. ### List all authorities
  140. ```ruby
  141. UKPlanningScraper::Authority.all.each { |a| puts a.name }
  142. ```
  143. ### List all tags
  144. ```ruby
  145. pp UKPlanningScraper::Authority.tags
  146. ```
  147. ## Add your favourite local planning authorities
  148. The list of authorities is in a CSV file in `/lib/uk_planning_scraper`:
  149. https://github.com/adrianshort/uk_planning_scraper/blob/master/lib/uk_planning_scraper/authorities.csv
  150. The easiest way to add to or edit this list is to edit within GitHub (use the
  151. pencil icon) and create a new pull request for your changes. If accepted, your
  152. changes will be available to everyone with the next version of the gem.
  153. The file format is one line per authority, with comma-separated:
  154. - Name (omit "the", "council", "borough of", "city of", etc. and write "and" not
  155. "&", except for `City of London` which is a special case)
  156. - URL of the search form (use the advanced search URL if there is one)
  157. - Tags (use as many comma-separated tags as is reasonable, lowercase and all one
  158. word.)
  159. There's no need to manually add tags to the `authorities.csv` file for the
  160. software systems like `idox`, `northgate` etc as these are added automatically.
  161. Please check the tag list before you change anything:
  162. ```ruby
  163. pp UKPlanningScraper::Authority.tags
  164. ```
  165. ## Development
  166. After checking out the repo, run `bin/setup` to install dependencies. You can
  167. also run `bin/console` for an interactive prompt that will allow you to
  168. experiment.
  169. To install this gem onto your local machine, run `bundle exec rake install`. To
  170. release a new version, update the version number in `version.rb`, and then run
  171. `bundle exec rake release`, which will create a git tag for the version, push
  172. git commits and tags, and push the `.gem` file to
  173. [rubygems.org](https://rubygems.org).
  174. ## Contributing
  175. Bug reports and pull requests are welcome on GitHub at
  176. https://github.com/adrianshort/uk_planning_scraper.