address not being parsed correct for apartments
![]() ![]() |
It seems that the address is not being properly parsed for apartments. I've posted an example posting below... In this example the address is listed (2456 20th Street NW), but instead of pulling the address CLFusion is showing the address as ADAMS MORGAN. How hard would it be to tweak it to pull the actual address when its available? Thanks,
The following is the detail text from http://washingtondc.craigslist.org/doc/apa/1571...: $1595 / 1br - Fully Furnished Apartment Available for Rent (Adams Morgan) (map)
$1,595 -- Fully Furnished 1 Bedroom/1 Full Bathroom Apartment Available for Rent Month to month lease available. Available Now! Large walk-in closet, wood floors, television, dishwasher, Brand New Gas Stove, Futon in living room, washer/dryer in building, Close to Metro, roof deck with view of park, elevator, secured entry --- in The Rockledge Building. Apartment is within a 3 mile radius of American University, Georgetown University, Howard University, Trinity College, Catholic University of America, St.Pauls College, Gallaudet University, Dupont Circle, Embassy Row, Rock Creek Park, and right next to the Smithsonian National Zoological Park. Please call Sean: 301.404.5525 or email eagle8524@aol.com 2456 20th Street NW (google map) (yahoo map) * cats are OK - purrr
|
![]() ![]() |
So, I did a little tweaking and I think I have it working for apartment listings. Updated parseLocation function is below. You just need to replace the current parseLocation section with this one. If the page is for apartments (based on the URL) I search for the more detailed address field that apartment listings have, if its not apartments I use the older Location approach. Thanks for a cool GM script, I hope this tweak helps others... d
this.parseSubstring = function(sourceString, startString, endString) {
var index = sourceString.indexOf(startString);
if (index < 0) {
return null;
}
var endIndex = sourceString.indexOf(endString, index);
if (endIndex < 0) {
return null;
}
return sourceString.substring(index + startString.length, endIndex);
}
this.parseLocation = function(details) {
var location;
// DavidRees - Use the more detailed street address in apartment listings
var xstreet0 = this.parseSubstring(details, "<!-- CLTAG xstreet0=", " -->");
var xstreet1 = this.parseSubstring(details, "<!-- CLTAG xstreet1=", " -->");
var city = this.parseSubstring(details, "<!-- CLTAG city=", " -->");
var region = this.parseSubstring(details, "<!-- CLTAG region=", " -->");
if (xstreet0 && city && region) {
// If it doesn't start with a number, assume this is just a street name
// Unfortunately doesn't handle things like 18st correctly
if (isNaN(xstreet0.substring(0,1))) {
street = xstreet0 + " at " + xstreet1
} else {
street = xstreet0;
}
location = street + ", " + city + ", " + region;
return location;
}
location = this.parseSubstring(details, "<!-- CLTAG GeographicArea=", " -->");
return location;
}
|
![]() ![]() |
Thanks for the feedback and the suggestion. I'll look into this further and hopefully a good improvement will come out of this. |
![]() ![]() |
Any progress on including this? I ask because I keep having to paste it in after you update :) |
![]() ![]() |
David, I will add this feature in the next feature update. Thanks. |


