Automatically exported from code.google.com/p/planningalerts
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.
 
 
 
 
 
 

65 rivejä
1.7 KiB

  1. #!/opt/local/bin/ruby
  2. description = nil
  3. address = nil
  4. ref = nil
  5. getaddress = false
  6. url = nil
  7. puts '<planning>
  8. <authority_name>City of Westminster</authority_name>
  9. <authority_short_name>Westminster</authority_short_name>
  10. <applications>'
  11. while line = gets
  12. if line.index('Proposal:')
  13. description = line.gsub('<tr><td class="tablefeature">Proposal:</td><td class="tablefeature">','').gsub('</td></tr>','').strip
  14. end
  15. if line.index('<tr><td><a href="currentsearch-details.cfm?CASENO=')
  16. ref = line.gsub('<tr><td><a href="currentsearch-details.cfm?CASENO=','').gsub('</a></td></tr>','').strip
  17. ref = ref[ref.index('>')+1..ref.length]
  18. url = line.gsub('<tr><td><a href="','')
  19. url = url[0, url.index('">')]
  20. end
  21. if getaddress
  22. getaddress = false if line.index('Proposal:')
  23. end
  24. if getaddress
  25. address += line.gsub('</td></tr>','').strip + ' '
  26. end
  27. if line.index('<tr><td class="tablefeature">Address:</td><td class="tablefeature">')
  28. address = line.gsub('<tr><td class="tablefeature">Address:</td><td class="tablefeature">','').strip + ' '
  29. getaddress = true
  30. end
  31. if line.index('</table>') and address
  32. puts '<application>'
  33. puts "<council_reference>#{ref}</council_reference>"
  34. puts "<address>#{address.strip}</address>"
  35. if address
  36. m = address.strip.match(/[A-Z]?[A-Z]\d?\d \d[A-Z][A-Z]/)
  37. if m
  38. puts "<postcode>#{m}</postcode>"
  39. else
  40. puts "<postcode></postcode>"
  41. end
  42. end
  43. puts "<description>#{description}</description>"
  44. puts "<info_url>http://www3.westminster.gov.uk/planningapplications/#{url}</info_url>"
  45. puts "<comment_url></comment_url>"
  46. puts '</application>'
  47. end
  48. end
  49. puts '</applications>'
  50. puts '</planning>'