Craigslist Fusion

By Vy Ho Last update Apr 29, 2011 — Installed 15,055 times.

address not being parsed correct for apartments

in
Subscribe to address not being parsed correct for apartments 5 posts, 2 voices



David Rees User
FirefoxWindows

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,
dave

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)
Date: 2010-01-26, 2:01PM EST
Reply to: hous-mutqq-1571664552@craigslist.org [Errors when replying to ads?]

$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
* Location: Adams Morgan
* it's NOT ok to contact this poster with services or other commercial interests

 
David Rees User
FirefoxWindows

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;
    }

 
Vy Ho Script's Author
FirefoxWindows

Thanks for the feedback and the suggestion. I'll look into this further and hopefully a good improvement will come out of this.

 
David Rees User
FirefoxWindows

Any progress on including this? I ask because I keep having to paste it in after you update :)

 
Vy Ho Script's Author
FirefoxX11

David, I will add this feature in the next feature update. Thanks.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel