Skip to content

Instantly share code, notes, and snippets.

@niallsmart
Created February 13, 2011 19:24
Show Gist options
  • Save niallsmart/824980 to your computer and use it in GitHub Desktop.
Save niallsmart/824980 to your computer and use it in GitHub Desktop.
Simple JQuery snippet to extract Craigslist search results to CSV
$("p.row").each(function(index) {
var csv = $(this).text().trim().replace(/[ \r\n\t]+/g, ' ');
csv = csv.replace(/ pic$/, "\tpic")
csv = csv.replace(/ pic img$/, "\tpic img")
csv = csv.replace(/^([^-]*)- /, "$1\t")
csv = csv.replace(/ - ([($])/, "\t$1")
//csv = csv.replace(/(\$[0-9]+) ([^(])/, "$1\t\t$2")
//csv = csv.replace(/ - /g, "\t")
//csv = csv.replace(/\tby owner/g, " - by owner,")
csv = csv.replace(/ *\(([^)(]+)\) *([^(]+)?$/g, "\t$1\t$2")
console.log(csv);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment