Created
January 8, 2011 00:38
-
-
Save ericmoritz/770375 to your computer and use it in GitHub Desktop.
Calculates the average price for a craigslist search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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)); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!