Which federal electorate(s) each Australian locality and postcode is in, scraped from the Australian Electoral Commission's locality search.
It replaces drzax/morph-division-postcode-correspondence as the source for parse-postcodes.rb in openaustralia-parser, which loads the postcode lookup used by OpenAustralia.org.au and They Vote for You. See openaustralia/openaustralia#1060.
The data table has one row for each locality and electorate. A locality split between electorates has a row for each of them.
| Column | Example | Notes |
|---|---|---|
| state | NSW | |
| locality | CAMMERAY | |
| postcode | 2062 | |
| other_localities | ST LEONARDS | Blank for most localities |
| electorate | Bradfield | |
| electorate_type | current | redistributed for the electorate a locality moves to at the next federal election, after a redistribution |
Each run replaces all the data, so abolished electorates don't linger. The run stops without saving if the data looks incomplete, for example when an electorate has no localities, keeping the previous run's data.
To get the postcode to electorate mapping that parse-postcodes.rb expects:
sql
SELECT DISTINCT postcode, electorate FROM data WHERE electorate_type = 'current' ORDER BY postcode, electorate
bundle config set --local path vendor/bundle
bundle install
bundle exec ruby scraper.rb
A full run makes about 1,000 requests to electorate.aec.gov.au, one at a time, and takes about 5 minutes. Set MORPH_AUSTRALIAN_PROXY to send them through the Australian proxy.
bundle exec rake
bundle exec rubocop
The specs use the saved AEC pages in spec/fixtures/ and don't contact any site.
This is a scraper that runs on morph.io. To get started see the documentation.
To download data sign in with GitHub
rows 10 / 20609
| state | locality | postcode | other_localities | electorate | electorate_type |
|---|---|---|---|---|---|
|
SA
|
ADELAIDE
|
5000
|
|
Adelaide
|
current
|
|
SA
|
ADELAIDE
|
5000
|
|
Adelaide
|
redistributed
|
|
SA
|
ALLENBY GARDENS
|
5009
|
|
Adelaide
|
current
|
|
SA
|
ALLENBY GARDENS
|
5009
|
|
Adelaide
|
redistributed
|
|
SA
|
ANGLE PARK
|
5010
|
|
Adelaide
|
current
|
|
SA
|
ANGLE PARK
|
5010
|
|
Adelaide
|
redistributed
|
|
SA
|
ASHFORD
|
5035
|
|
Adelaide
|
current
|
|
SA
|
ASHFORD
|
5035
|
|
Adelaide
|
redistributed
|
|
SA
|
BLAIR ATHOL
|
5084
|
|
Adelaide
|
current
|
|
SA
|
BLAIR ATHOL
|
5084
|
|
Adelaide
|
redistributed
|
Average successful run time: 10 minutes
Total run time: 20 minutes
Total cpu time used: half a minute
Total disk space used: 2.08 MB