Skip to content

Instantly share code, notes, and snippets.

@ericmoritz
Created January 8, 2011 00:38
Show Gist options
  • Select an option

  • Save ericmoritz/770375 to your computer and use it in GitHub Desktop.

Select an option

Save ericmoritz/770375 to your computer and use it in GitHub Desktop.
Calculates the average price for a craigslist search
(function() {
var total = 0;
var count = 0;
jQuery("p > a").each(function(i) {
var $this = jQuery(this);
var bits = $this.html().split(/ /);
var price = new Number(bits[0].substring(1));
if(!isNaN(price)) {
total += price;
count++;
}
});
alert("Average: " + (total/count));
})();
@elmaximo
Copy link

elmaximo commented Nov 3, 2014

Hi: I am trying to find a method of finding average sale price for given search results on CL. For example I search for 2005 Honda Civic (in title) and get results. I want to see average asking price. I this what the code does? How is this code implemented into a site? Is there a URL example we can see/demo? Thanks!

@bjinwright
Copy link

This script does this for a single page.

@brendonharrison
Copy link

Check out www.cldata.io for Craigslist pricing data.

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