Automatically exported from code.google.com/p/planningalerts
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

PlanningExplorer.py 26 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. import urllib2
  2. import urllib
  3. import urlparse
  4. import cgi
  5. import re
  6. import datetime
  7. from BeautifulSoup import BeautifulSoup
  8. from PlanningUtils import PlanningApplication, \
  9. PlanningAuthorityResults, \
  10. getPostcodeFromText
  11. # Date format to enter into search boxes
  12. date_format = "%d/%m/%Y"
  13. # Regex for getting the application code
  14. # (needed for the comments url, when it exists)
  15. app_code_regex = re.compile("PARAM0=(\d*)")
  16. class PlanningExplorerParser:
  17. # If this authority doesn't have a comments page,
  18. # then set this email_address to an address for the
  19. # planning department, and it will be used in lieu of
  20. # a comments url.
  21. comments_email_address = None
  22. # These are the directories where the info urls, and search urls,
  23. # usually live underneath the base_url.
  24. # If these are different for a particular
  25. # authority, then they can be overridden in a subclass.
  26. info_url_path = "MVM/Online/Generic/"
  27. search_url_path = "MVM/Online/PL/GeneralSearch.aspx"
  28. # This is the most common place for comments urls to live
  29. # The %s will be filled in with an application code
  30. comments_path = "MVM/Online/PL/PLComments.aspx?pk=%s"
  31. # Most authorities don't need the referer header on the post
  32. # request. If one does, override this in the subclass
  33. use_referer = False
  34. # Some authorities won't give us anything back if we use the
  35. # python urllib2 useragent string. In that case, override this
  36. # in a subclass to pretend to be firefox.
  37. use_firefox_user_agent = False
  38. # This is the most common css class of the table containing the
  39. # the search results. If it is different for a particular authority
  40. # it can be overridden in a subclass
  41. results_table_attrs = {"class": "ResultsTable"}
  42. # These are the most common column positions for the
  43. # council reference, the address, and the description
  44. # in the results table.
  45. # They should be overridden in subclasses if they are different
  46. # for a particular authority.
  47. reference_td_no = 0
  48. address_td_no = 1
  49. description_td_no = 2
  50. # In some cases we won't be able to get the full address/description/postcode without getting the info page for each app.
  51. # If fetch_info_page is set to true, then we need to get a copy of the info page and store it as an attribute on current_application (naughty!)
  52. fetch_info_page = False
  53. def _modify_response(self, response):
  54. """For most sites, we have managed to get all the apps on a
  55. single page by choosing the right parameters.
  56. If that hasn't been possible, override this method to get a
  57. new response object which has all the apps in one page.
  58. (See, for example, Hackney).
  59. """
  60. return response
  61. def _find_trs(self, results_table):
  62. """Normally, we just want a list of all the trs except the first one
  63. (which is usually a header).
  64. If the authority requires a different list of trs, override this method.
  65. """
  66. return results_table.findAll("tr")[1:]
  67. def _sanitisePostHtml(self, html):
  68. """This method can be overriden in subclasses if the
  69. html that comes back from the post request is bad, and
  70. needs tidying up before giving it to BeautifulSoup."""
  71. return html
  72. def _sanitiseInfoUrl(self, url):
  73. """If an authority has info urls which are for some reason full
  74. of crap (like Broadland does), then this method should be overridden
  75. in order to tidy them up."""
  76. return url
  77. def _getHeaders(self):
  78. """If the authority requires any headers for the post request,
  79. override this method returning a dictionary of header key to
  80. header value."""
  81. headers = {}
  82. if self.use_firefox_user_agent:
  83. headers["User-Agent"] = "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.10) Gecko/20071126 Ubuntu/7.10 (gutsy) Firefox/2.0.0.10"
  84. if self.use_referer:
  85. headers["Referer"] = self.search_url
  86. return headers
  87. def _getPostData(self, asp_args, search_date):
  88. """Accepts asp_args (a tuple of key value pairs of the pesky ASP
  89. parameters, and search_date, a datetime.date object for the day
  90. we are searching for.
  91. This seems to be the most common set of post data which is needed
  92. for PlanningExplorer sites. It won't work for all of them, so
  93. will sometimes need to be overridden in a subclass.
  94. The parameter edrDateSelection is often not needed.
  95. It is needed by Charnwood though, so I've left it in
  96. to keep things simple.
  97. """
  98. year_month_day = search_date.timetuple()[:3]
  99. post_data = urllib.urlencode(asp_args + (
  100. ("_ctl0", "DATE_RECEIVED"),
  101. ("rbGroup", "_ctl5"),
  102. ("_ctl7_hidden", urllib.quote('<DateChooser Value="%d%%2C%d%%2C%d"><ExpandEffects></ExpandEffects></DateChooser>' %year_month_day)),
  103. ("_ctl8_hidden", urllib.quote('<DateChooser Value="%d%%2C%d%%2C%d"><ExpandEffects></ExpandEffects></DateChooser>' %year_month_day)),
  104. ("edrDateSelection", "1"),
  105. ("csbtnSearch", "Search"),
  106. ("cboNumRecs", "99999"),
  107. ))
  108. return post_data
  109. def _getAddress(self, tds, info_soup):
  110. # If this td contains a div, then the address is the
  111. # string in there - otherwise, use the string in the td.
  112. address_td = tds[self.address_td_no]
  113. if address_td.div is not None:
  114. address = address_td.div.string
  115. else:
  116. address = address_td.string
  117. return address
  118. def _getPostCode(self, info_soup):
  119. """In most cases, the postcode can be got from the address in
  120. the results table. Some councils put the address there without the
  121. postcode. In this case we will have to go to the info page to get
  122. the postcode. This should be done by overriding this method with
  123. one that parses the info page."""
  124. return getPostcodeFromText(self._current_application.address)
  125. def _getDescription(self, tds, info_soup):
  126. description_td = tds[self.description_td_no]
  127. if description_td.div is not None:
  128. # Mostly this is in a div
  129. # Use the empty string if the description is missing
  130. description = description_td.div.string or ""
  131. else:
  132. # But sometimes (eg Crewe) it is directly in the td.
  133. # Use the empty string if the description is missing
  134. description = description_td.string or ""
  135. return description
  136. def __init__(self,
  137. authority_name,
  138. authority_short_name,
  139. base_url,
  140. debug=False):
  141. self.authority_name = authority_name
  142. self.authority_short_name = authority_short_name
  143. self.base_url = base_url
  144. self.search_url = urlparse.urljoin(base_url, self.search_url_path)
  145. self.info_url_base = urlparse.urljoin(self.base_url, self.info_url_path)
  146. self.debug = debug
  147. self._results = PlanningAuthorityResults(self.authority_name, self.authority_short_name)
  148. def getResultsByDayMonthYear(self, day, month, year):
  149. search_date = datetime.date(year, month, day)
  150. # First do a get, to get some state
  151. get_request = urllib2.Request(self.search_url)
  152. get_response = urllib2.urlopen(get_request)
  153. html = get_response.read()
  154. # We need to find those ASP parameters such as __VIEWSTATE
  155. # so we can use them in the next POST
  156. asp_args_regex = re.compile('<input[^>]*name=\"(__[A-Z]*)\"[^>]*value=\"([^\"]*)\"[^>]*>')
  157. # re.findall gets us a list of key value pairs.
  158. # We want to concatenate it with a tuple, so we must
  159. # make it a tuple
  160. asp_args = tuple(re.findall(asp_args_regex, html))
  161. # The post data needs to be different for different councils
  162. # so we have a method on each council's scraper to make it.
  163. post_data = self._getPostData(asp_args, search_date)
  164. headers = self._getHeaders()
  165. request = urllib2.Request(self.search_url, post_data, headers)
  166. post_response = urllib2.urlopen(request)
  167. # We have actually been returned here by an http302 object
  168. # moved, and the response called post_response is really a get.
  169. # In some cases, we can't get the page size set high
  170. # until now. In that case, override _modify_response
  171. # so that we get back a response with all the apps on one page.
  172. # We pass in headers so that any
  173. post_response = self._modify_response(post_response)
  174. html = self._sanitisePostHtml(post_response.read())
  175. soup = BeautifulSoup(html)
  176. results_table = soup.find("table", attrs=self.results_table_attrs)
  177. # If there is no results table, then there were no apps on that day.
  178. if results_table:
  179. trs = self._find_trs(results_table)
  180. self._current_application = None
  181. # The first tr is just titles, cycle through the trs after that
  182. for tr in trs:
  183. self._current_application = PlanningApplication()
  184. # There is no need to search for the date_received, it's what
  185. # we searched for
  186. self._current_application.date_received = search_date
  187. tds = tr.findAll("td")
  188. self._current_application.council_reference = tds[self.reference_td_no].a.string
  189. relative_info_url = self._sanitiseInfoUrl(tds[self.reference_td_no].a['href'])
  190. self._current_application.info_url = urlparse.urljoin(self.info_url_base, relative_info_url)
  191. # Fetch the info page if we need it, otherwise set it to None
  192. if self.fetch_info_page:
  193. # We need to quote the spaces in the info url
  194. info_request = urllib2.Request(urllib.quote(self._current_application.info_url, ":/&?="))
  195. info_soup = BeautifulSoup(urllib2.urlopen(info_request))
  196. else:
  197. info_soup = None
  198. # What about a comment url?
  199. # There doesn't seem to be one, so we'll use the email address
  200. if self.comments_email_address is not None:
  201. # We're using the email address, as there doesn't seem
  202. # to be a web form for comments
  203. self._current_application.comment_url = self.comments_email_address
  204. else:
  205. # This link contains a code which we need for the comments url
  206. # (on those sites that use it)
  207. application_code = app_code_regex.search(relative_info_url).groups()[0]
  208. relative_comments_url = self.comments_path %(application_code)
  209. self._current_application.comment_url = urlparse.urljoin(self.base_url, relative_comments_url)
  210. self._current_application.address = self._getAddress(tds, info_soup)
  211. self._current_application.postcode = self._getPostCode(info_soup)
  212. self._current_application.description = self._getDescription(tds, info_soup)
  213. self._results.addApplication(self._current_application)
  214. return self._results
  215. def getResults(self, day, month, year):
  216. return self.getResultsByDayMonthYear(int(day), int(month), int(year)).displayXML()
  217. class BroadlandLike:
  218. # FIXME - BroadlandLike authorities don't have postcodes on their site, but
  219. # they do have grid references. We should use these.
  220. results_table_attrs = {"class": "display_table"}
  221. info_url_path = "Northgate/PlanningExplorer/Generic/"
  222. search_url_path = "Northgate/PlanningExplorer/GeneralSearch.aspx"
  223. use_firefox_user_agent = True
  224. use_referer = True
  225. def _getPostData(self, asp_args, search_date):
  226. post_data = urllib.urlencode(asp_args + (
  227. ("cboSelectDateValue", "DATE_RECEIVED"),
  228. ("rbGroup", "rbRange"),
  229. ("dateStart", search_date.strftime(date_format)),
  230. ("dateEnd", search_date.strftime(date_format)),
  231. ("cboNumRecs", "99999"),
  232. ("csbtnSearch", "Search"),
  233. ))
  234. return post_data
  235. def _sanitiseInfoUrl(self, url):
  236. """The broadland info urls arrive full of rubbish. This method tidies
  237. them up."""
  238. # We need to
  239. # 1) Remove whitespace
  240. # 2) Remove &#xA; and &#xD;
  241. ws_re = re.compile("(?:(?:\s)|(?:&#x\w;))*")
  242. return ''.join(ws_re.split(url))
  243. class BlackburnParser(PlanningExplorerParser):
  244. use_firefox_user_agent = True
  245. class BroadlandParser(BroadlandLike, PlanningExplorerParser):
  246. # FIXME - is http://secure.broadland.gov.uk/mvm/Online/PL/GeneralSearch.aspx
  247. # a better url for Broadland?
  248. def _sanitisePostHtml(self, html):
  249. """The page that comes back from the post for the broadland site
  250. has a broken doctype declaration. We need to tidy that up before
  251. giving it to BeautifulSoup."""
  252. # This is what it looks like - note the missing close doublequote
  253. #<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
  254. # Split on the broken doctype and join with the doctype with
  255. # closing quote.
  256. html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.join(html.split('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>'))
  257. return html
  258. class CamdenParser(BroadlandLike, PlanningExplorerParser):
  259. comments_path = "Northgate/PlanningExplorer/PLComments.aspx?pk=%s"
  260. class CharnwoodParser(PlanningExplorerParser):
  261. use_firefox_user_agent = True
  262. class CreweParser(PlanningExplorerParser):
  263. use_firefox_user_agent = True
  264. address_td_no = 4
  265. def _getPostData(self, asp_args, search_date):
  266. year_month_day = search_date.timetuple()[:3]
  267. post_data = urllib.urlencode(asp_args + (
  268. ("drDateReceived:_ctl0_hidden", urllib.quote('<DateChooser Value="%d%%2C%d%%2C%d"><ExpandEffects></ExpandEffects></DateChooser>' %year_month_day)),
  269. ("drDateReceivedxxctl0_input", search_date.strftime(date_format)),
  270. ("drDateReceived:_ctl1_hidden", urllib.quote('<DateChooser Value="%d%%2C%d%%2C%d"><ExpandEffects></ExpandEffects></DateChooser>' %year_month_day)),
  271. ("drDateReceivedxxctl1_input", search_date.strftime(date_format)),
  272. ("cboNumRecs", "99999"),
  273. ("csbtnSearch", "Search"),
  274. ))
  275. return post_data
  276. class EastStaffsParser(PlanningExplorerParser):
  277. use_firefox_user_agent = True
  278. address_td_no = 4
  279. description_td_no = 1
  280. class EppingForestParser(PlanningExplorerParser):
  281. use_firefox_user_agent = True
  282. address_td_no = 3
  283. description_td_no = 1
  284. class ForestHeathParser(BroadlandLike, PlanningExplorerParser):
  285. pass
  286. class HackneyParser(PlanningExplorerParser):
  287. # FIXME - This will only get the first ten records on this
  288. # day. Need to deal with paging.
  289. use_firefox_user_agent = True
  290. address_td_no = 6
  291. description_td_no = 5
  292. def _modify_response(self, response):
  293. # In order to make sure we don't have to worry about any paging,
  294. # We'll fetch this url again with PS=99999.
  295. real_url_tuple = urlparse.urlsplit(response.geturl())
  296. query_string = real_url_tuple[3]
  297. # Get the query as a list of key, value pairs
  298. parsed_query_list = list(cgi.parse_qsl(query_string))
  299. # Go through the query string replacing any PS parameters
  300. # with PS=99999
  301. for i in range(len(parsed_query_list)):
  302. key, value = parsed_query_list[i]
  303. if key == "PS":
  304. value = "99999"
  305. parsed_query_list[i] = (key, value)
  306. new_query_string = urllib.urlencode(parsed_query_list)
  307. new_url_tuple = real_url_tuple[:3] + (new_query_string,) + real_url_tuple[4:]
  308. new_url = urlparse.urlunsplit(new_url_tuple)
  309. new_request = urllib2.Request(new_url, None, self._getHeaders())
  310. new_response = urllib2.urlopen(new_request)
  311. return new_response
  312. def _getPostData(self, asp_args, search_date):
  313. post_data = urllib.urlencode(asp_args + (
  314. ("ctl00", "DATE_RECEIVED"),
  315. ("rbGroup", "ctl05"),
  316. ("ctl07_input", search_date.strftime(date_format)),
  317. ("ctl08_input", search_date.strftime(date_format)),
  318. ("edrDateSelection", "1"),
  319. ("csbtnSearch", "Search"),
  320. ))
  321. return post_data
  322. class KennetParser(BroadlandLike, PlanningExplorerParser):
  323. comments_path = "Northgate/PlanningExplorer/PLComments.aspx?pk=%s"
  324. class LincolnParser(PlanningExplorerParser):
  325. use_firefox_user_agent = True
  326. results_table_attrs = {"class": "resultstable"}
  327. class LiverpoolParser(PlanningExplorerParser):
  328. comments_email_address = "planningandbuildingcontrol@liverpool.gov.uk"
  329. use_firefox_user_agent = True
  330. use_referer = True
  331. results_table_attrs = {"xmlns:mvm":"http://www.mvm.co.uk"}
  332. info_url_path = "mvm/"
  333. search_url_path = "mvm/planningsearch.aspx"
  334. def _find_trs(self, results_table):
  335. """In this case we are after all trs except the first two which have a
  336. class attribute row0 or row1."""
  337. return results_table.findAll("tr", {"class":["row0", "row1"]})[3:]
  338. def _getPostData(self, asp_args, search_date):
  339. post_data = urllib.urlencode(asp_args + (
  340. ("dummy", "dummy field\tused for custom\tvalidator"),
  341. ("drReceived$txtStart", search_date.strftime(date_format)),
  342. ("drReceived$txtEnd", search_date.strftime(date_format)),
  343. ("cboNumRecs", "99999"),
  344. ("cmdSearch", "Search"),
  345. ))
  346. return post_data
  347. def _sanitiseInfoUrl(self, url):
  348. """The liverpool info urls arrive full of rubbish. This method tidies
  349. them up."""
  350. # We need to
  351. # 1) Remove whitespace
  352. # 2) Remove &#xA; and &#xD;
  353. ws_re = re.compile("(?:(?:\s)|(?:&#x\w;))*")
  354. return ''.join(ws_re.split(url))
  355. class MertonParser(PlanningExplorerParser):
  356. use_firefox_user_agent = True
  357. fetch_info_page = True
  358. def _getAddress(self, tds, info_soup):
  359. return info_soup.find(text="Site Address").findNext("td").string.strip()
  360. def _getDescription(self, tds, info_soup):
  361. return info_soup.find(text="Development Proposal").findNext("td").string.strip()
  362. class ShrewsburyParser(PlanningExplorerParser):
  363. use_firefox_user_agent = True
  364. class SouthNorfolkParser(PlanningExplorerParser):
  365. use_firefox_user_agent = True
  366. class SouthShropshireParser(PlanningExplorerParser):
  367. comments_email_address = "planning@southshropshire.gov.uk"
  368. use_firefox_user_agent = True
  369. info_url_path = "MVM/Online/PL/"
  370. def _getPostData(self, asp_args, search_date):
  371. local_date_format = "%d-%m-%Y"
  372. year, month, day = search_date.timetuple()[:3]
  373. post_data = urllib.urlencode(asp_args + (
  374. ("edrDateSelection:htxtRange", "radRangeBetween"),
  375. ("cboDateList", "DATE_RECEIVED"),
  376. ("edrDateSelection:txtStart", search_date.strftime(local_date_format)),
  377. ("edrDateSelection:txtEnd", search_date.strftime(local_date_format)),
  378. ("edrDateSelection:txtDateReceived", "%(day)d-%(month)d-%(year)d~%(day)d-%(month)d-%(year)d" %({"day":day, "month":month, "year":year})),
  379. ("cboNumRecs", "99999"),
  380. ("csbtnSearch", "Search"),
  381. ))
  382. return post_data
  383. class SouthTynesideParser(BroadlandLike, PlanningExplorerParser):
  384. # Unlike the other BroadlandLike sites, there are postcodes :-)
  385. pass
  386. class StockportParser(PlanningExplorerParser):
  387. comments_email_address = "admin.dc@stockport.gov.uk"
  388. info_url_path = "MVM/Online/PL/"
  389. def _getPostData(self, asp_args, search_date):
  390. post_data = urllib.urlencode(asp_args + (
  391. ("drDateReceived:txtStart", search_date.strftime(date_format)),
  392. ("drDateReceived:txtEnd", search_date.strftime(date_format)),
  393. ("cboNumRecs", "99999"),
  394. ("csbtnSearch", "Search"),),
  395. )
  396. return post_data
  397. class SwanseaParser(BroadlandLike, PlanningExplorerParser):
  398. # Unlike the other BroadlandLike sites, there are postcodes :-)
  399. pass
  400. class TamworthParser(PlanningExplorerParser):
  401. comments_email_address = "planningadmin@tamworth.gov.uk"
  402. use_firefox_user_agent = True
  403. info_url_path = "MVM/Online/PL/"
  404. class TraffordParser(PlanningExplorerParser):
  405. # There are no postcodes on the Trafford site.
  406. use_firefox_user_agent = True
  407. address_td_no = 3
  408. class WestOxfordshireParser(PlanningExplorerParser):
  409. address_td_no = 3
  410. description_td_no = 1
  411. use_firefox_user_agent = True
  412. class WalthamForestParser(PlanningExplorerParser):
  413. address_td_no = 2
  414. description_td_no = 3
  415. search_url_path = "PlanningExplorer/GeneralSearch.aspx"
  416. info_url_path = "PlanningExplorer/Generic/"
  417. use_firefox_user_agent = True
  418. def _getPostData(self, asp_args, search_date):
  419. post_data = urllib.urlencode(asp_args + (
  420. ("txtApplicantName", ""),
  421. ("txtAgentName", ""),
  422. ("cboStreetReferenceNumber", ""),
  423. ("txtProposal", ""),
  424. ("cboWardCode", ""),
  425. ("cboParishCode", ""),
  426. ("cboApplicationTypeCode", ""),
  427. ("cboDevelopmentTypeCode", ""),
  428. ("cboStatusCode", ""),
  429. ("cboSelectDateValue", "DATE_RECEIVED"),
  430. ("cboMonths", "1"),
  431. ("cboDays", "1"),
  432. ("rbGroup", "rbRange"),
  433. ("dateStart", search_date.strftime(date_format)),
  434. ("dateEnd", search_date.strftime(date_format)),
  435. #&dateStart=01%2F03%2F2008&dateEnd=01%2F04%2F2008&
  436. ("edrDateSelection", ""),
  437. ("csbtnSearch", "Search"),
  438. ))
  439. print post_data
  440. return post_data
  441. class ConwyParser(BroadlandLike, PlanningExplorerParser):
  442. search_url_path = "Northgate/planningexplorerenglish/generalsearch.aspx"
  443. info_url_path = "Northgate/PlanningExplorerEnglish/Generic/"
  444. comments_path = "Northgate/PlanningExplorerEnglish/PLComments.aspx?pk=%s"
  445. use_firefox_user_agent = True
  446. #&txtApplicationNumber=&txtProposal=&txtSiteAddress=&cboWardCode=&cboParishCode=&cboApplicationTypeCode=&cboDevelopmentTypeCode=&cboStatusCode=&cboSelectDateValue=DATE_RECEIVED&cboMonths=1&cboDays=1&rbGroup=rbRange&dateStart=10%2F07%2F2008&dateEnd=20%2F07%2F2008&edrDateSelection=&csbtnSearch=Search
  447. #txtApplicantName=
  448. #txtAgentName=
  449. #cboStreetReferenceNumber=
  450. #txtProposal=
  451. #cboWardCode=
  452. #cboParishCode=
  453. #cboApplicationTypeCode=
  454. #cboDevelopmentTypeCode=
  455. #cboStatusCode=
  456. #cboSelectDateValue=DATE_RECEIVED
  457. #cboMonths=1
  458. #cboDays=1
  459. #rbGroup=rbRange
  460. #dateStart=01%2F03%2F2008
  461. #dateEnd=01%2F04%2F2008
  462. #edrDateSelection=
  463. #csbtnSearch=Search
  464. if __name__ == '__main__':
  465. # NOTE - 04/11/2007 is a sunday
  466. # I'm using it to test that the scrapers behave on days with no apps.
  467. parser = BlackburnParser("Blackburn With Darwen Borough Council", "Blackburn", "http://195.8.175.6/")
  468. # parser = BroadlandParser("Broadland Council", "Broadland", "http://www.broadland.gov.uk/")
  469. # parser = CamdenParser("London Borough of Camden", "Camden", "http://planningrecords.camden.gov.uk/")
  470. # parser = CharnwoodParser("Charnwood Borough Council", "Charnwood", "http://portal.charnwoodbc.gov.uk/")
  471. # parser = CreweParser("Crewe and Nantwich Borough Council", "Crewe and Nantwich", "http://portal.crewe-nantwich.gov.uk/")
  472. # parser = EastStaffsParser("East Staffordshire Borough Council", "East Staffs", "http://www2.eaststaffsbc.gov.uk/")
  473. # parser = EppingForestParser("Epping Forest District Council", "Epping Forest", "http://plan1.eppingforestdc.gov.uk/")
  474. # parser = ForestHeathParser("Forest Heath District Council", "Forest Heath", "http://195.171.177.73/")
  475. # parser = HackneyParser("London Borough of Hackney", "Hackney", "http://www.hackney.gov.uk/servapps/")
  476. # parser = KennetParser("Kennet District Council", "Kennet", "http://mvm-planning.kennet.gov.uk/")
  477. # parser = LincolnParser("Lincoln City Council", "Lincoln", "http://online.lincoln.gov.uk/")
  478. # parser = LiverpoolParser("Liverpool City Council", "Liverpool", "http://www.liverpool.gov.uk/")
  479. # parser = ShrewsburyParser("Shrewsbury and Atcham Borough Council", "Shrewsbury", "http://www2.shrewsbury.gov.uk/")
  480. # parser = SouthNorfolkParser("South Norfolk Council", "South Norfolk", "http://planning.south-norfolk.gov.uk/")
  481. # parser = SouthShropshireParser("South Shropshire District Council", "South Shropshire", "http://194.201.44.102/")
  482. # parser = SouthTynesideParser("South Tyneside Council", "South Tyneside", "http://poppy.southtyneside.gov.uk/")
  483. # parser = StockportParser("Stockport Metropolitan District Council", "Stockport", "http://s1.stockport.gov.uk/council/eed/dc/planning/")
  484. # parser = SwanseaParser("Swansea City and County Council", "Swansea", "http://www2.swansea.gov.uk/")
  485. # parser = TamworthParser("Tamworth Borough Council", "Tamworth", "http://80.1.64.77/")
  486. # parser = TraffordParser("Trafford Council", "Trafford", "http://planning.trafford.gov.uk/")
  487. # parser = WestOxfordshireParser("West Oxfordshire District Council", "West Oxfordshire", "http://planning.westoxon.gov.uk/")
  488. # parser = WalthamForestParser("Waltham Forest", "Waltham Forest", "http://planning.walthamforest.gov.uk/")
  489. # parser = ConwyParser("Conwy County Borough Council", "Conwy", "http://www.conwy.gov.uk/")
  490. # parser = MertonParser("London Borough of Merton", "Merton", "http://planning.merton.gov.uk")
  491. print parser.getResults(3, 7, 2008)
  492. # To Do
  493. # Sort out paging:
  494. # South Shropshire - pages on 6
  495. # Investigate catching unavailable message:
  496. # Charnwood
  497. # South Norfolk has no postcodes. I wonder if the postcodes are in the WAM site...