Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marianogappa/a8ac828638ef15f8944fa35213d0e117 to your computer and use it in GitHub Desktop.
Save marianogappa/a8ac828638ef15f8944fa35213d0e117 to your computer and use it in GitHub Desktop.
Average weekly rent price for advertised carparks on Auckland City Centre
# The following one-liner calculates the average weekly rent price for a carpark on Auckland City Centre (New Zealand)
curl -s 'http://www.trademe.co.nz/Browse/CategoryAttributeSearchResults.aspx?search=1&cid=5748&sidebar=1&132=FLAT&selected135=7&134=1&135=7&136=89&216=0&216=0&217=0&217=0&153=&29=Car+park&59=0&59=0&178=0&178=0' | grep 'per week</' | sed 's/.*\$\(.*\) per week.*/\1/g' | awk '{ sum += $1; n++ } END { if (n > 0) print "$" sum / n " based on " n " advertised items."; }'
# Example output (2016-08-20): $77.7917 based on 24 advertised items.
#
#
# Note that this script doesn't consider pagination, but I tried a whole-country search
# of carparks and there were only 78 results, and Trademe didn't paginate, so I think
# it's not necessary.
@marianogappa
Copy link
Author

Can be used for any trade me page that has "per week" items; just replace the url. Beware of pagination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment