|
@@ -1,4 +1,4 @@
|
|
|
-# Hobart City Council – PlanBuild “Currently Advertised” scraper
|
|
|
|
|
|
|
+# Hobart City Council – PlanBuild "Currently Advertised" scraper
|
|
|
# Table name is injected by run_all.sh as TABLE_NAME=da_hobartcity
|
|
# Table name is injected by run_all.sh as TABLE_NAME=da_hobartcity
|
|
|
|
|
|
|
|
require "nokogiri"
|
|
require "nokogiri"
|
|
@@ -36,7 +36,7 @@ result_blocks.each do |blk|
|
|
|
address = address_el&.text&.strip.to_s
|
|
address = address_el&.text&.strip.to_s
|
|
|
council_reference = ref_el&.text&.strip.to_s
|
|
council_reference = ref_el&.text&.strip.to_s
|
|
|
|
|
|
|
|
- # Fallbacks from label-value pairs (e.g., “Address: …”, “Reference: …”)
|
|
|
|
|
|
|
+ # Fallbacks from label-value pairs (e.g., "Address: …", "Reference: …")
|
|
|
if address.empty?
|
|
if address.empty?
|
|
|
m = text.match(/Address:\s*(.+?)(?:\s{2,}|Reference:|$)/i)
|
|
m = text.match(/Address:\s*(.+?)(?:\s{2,}|Reference:|$)/i)
|
|
|
address = m[1].strip if m
|
|
address = m[1].strip if m
|
|
@@ -49,12 +49,12 @@ result_blocks.each do |blk|
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
# Try to find the LGA/council name in the block text
|
|
# Try to find the LGA/council name in the block text
|
|
|
- # Common patterns: “Council: Hobart City Council” or a badge/label nearby
|
|
|
|
|
|
|
+ # Common patterns: "Council: Hobart City Council" or a badge/label nearby
|
|
|
council_name = nil
|
|
council_name = nil
|
|
|
if (m = text.match(/Council:\s*([A-Za-z \-]+Council)/i))
|
|
if (m = text.match(/Council:\s*([A-Za-z \-]+Council)/i))
|
|
|
council_name = m[1].strip
|
|
council_name = m[1].strip
|
|
|
end
|
|
end
|
|
|
- # Light filter: if a filter is set and we can’t see Hobart in this block, skip it
|
|
|
|
|
|
|
+ # Light filter: if a filter is set and we can't see Hobart in this block, skip it
|
|
|
if COUNCIL_FILTER != "" && council_name && !council_name.include?(COUNCIL_FILTER)
|
|
if COUNCIL_FILTER != "" && council_name && !council_name.include?(COUNCIL_FILTER)
|
|
|
next
|
|
next
|
|
|
elsif COUNCIL_FILTER != "" && council_name.nil?
|
|
elsif COUNCIL_FILTER != "" && council_name.nil?
|
|
@@ -75,7 +75,7 @@ result_blocks.each do |blk|
|
|
|
end
|
|
end
|
|
|
date_received = Util.parse_aus_date(date_received_raw)
|
|
date_received = Util.parse_aus_date(date_received_raw)
|
|
|
|
|
|
|
|
- # If we still don’t have key fields, skip
|
|
|
|
|
|
|
+ # If we still don't have key fields, skip
|
|
|
next if address.empty? || council_reference.empty?
|
|
next if address.empty? || council_reference.empty?
|
|
|
|
|
|
|
|
DB.upsert(TABLE, {
|
|
DB.upsert(TABLE, {
|
|
@@ -84,7 +84,7 @@ result_blocks.each do |blk|
|
|
|
date_received_raw: date_received_raw,
|
|
date_received_raw: date_received_raw,
|
|
|
address: address,
|
|
address: address,
|
|
|
council_reference: council_reference,
|
|
council_reference: council_reference,
|
|
|
- applicant: "", # PlanBuild usually doesn’t expose these in the list
|
|
|
|
|
|
|
+ applicant: "", # PlanBuild usually doesn't expose these in the list
|
|
|
owner: ""
|
|
owner: ""
|
|
|
})
|
|
})
|
|
|
|
|
|