Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var i, cheerio = require('cheerio'), request = require('request');
- function scrapeSuburb(err, response, html) {
- if (!err) {
- var $ = cheerio.load(html);
- $('.resultsList tbody tr').each(function () {
- var suburbDoc, suburbName = $(this).find('.second a').html().split(', ');
- if (suburbName && suburbName.length > 1) {
- suburbDoc = {
- postCode: $(this).find('.first a').html(),
- suburbName: suburbName[0],
- state: suburbName[1]
- };
- //do with it what you will
- }
- });
- }
- }
- for (i = 97; i < 123; i += 1) {
- request(
- 'http://auspost.com.au/postcode/' + String.fromCharCode(i),
- scrapeSuburb
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement