Skip to content

Instantly share code, notes, and snippets.

@o-sam-o
Created September 10, 2011 05:21
Show Gist options
  • Save o-sam-o/1207966 to your computer and use it in GitHub Desktop.
Save o-sam-o/1207966 to your computer and use it in GitHub Desktop.
Hobart City Council Development Applications
require 'nokogiri'
require 'open-uri'
require 'date'
require "awesome_print"
url = "http://www.hobartcity.com.au/go/AdvertisedApps/output.html"
doc = Nokogiri::HTML(open(url))
table = doc.at_css('table')
headers = table.css('th').collect { |th| th.inner_text.strip }
das_data = table.css('tbody tr:not(.rowHidden)').collect do |tr|
tr.css('td').collect { |td| td.inner_text.strip }
end
comment_url = 'mailto:[email protected]?Subject=Development Application Enquiry: '
das = das_data.collect do |da_item|
page_info = {}
page_info[:council_reference] = da_item[headers.index('DA Number')]
# No direct link :(
page_info[:info_url] = 'http://www.hobartcity.com.au/advertisedapps'
page_info[:description] = da_item[headers.index('Proposed Development')]
page_info[:date_received] = Date.today.to_s
page_info[:address] = da_item[headers.index('Address')]
page_info[:on_notice_to] = Date.strptime(da_item[headers.index('Representation Period Expiry Date')], '%d %B %Y').to_s
page_info[:date_scraped] = Date.today.to_s
page_info[:comment_url] = comment_url + da_item[headers.index('DA Number')]
page_info
end
ap das
p 'Done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment