node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป



Nodejs utilities for scraping/crawling/working with craigslist

lookup_city(subdomain, area_code)

Lookup a city and optionally a neighborhood's information on craigslist by the city's subdomain, and the three letter representation of the neighborhood.

cl.lookup_city("seattle", "tac")

 > { city: 'seattle-tacoma',
 >   subdomain: 'seattle',
 >   state: 'Washington',
 >   continent: 'US',
 >   areas: 
 >   [ { name: 'seattle', path: 'see' },
 >     { name: 'eastside', path: 'est' },
 >     { name: 'snohomish co', path: 'sno' },
 >     { name: 'kitsap co', path: 'kit' },
 >     { name: 'tacoma', path: 'tac' },
 >     { name: 'olympia', path: 'oly' },
 >     { name: 'south king', path: 'skc' } ],
 >   area_name: 'tacoma',
 >   area_path: 'tac' });


Lookup the category and subcategory name given it's three-letter code.


 > {code: 'muc',
 >  name: 'musicians',
 >  parent: {code: 'ccc',
 >    name: 'community'}});


Lookup a discussion form name given it's numerical ID


 > {name: "apple",
 >  id: "3232",
 >  path: "/forums/?forumID=3232"}

get_url(subdomain, cat_code, sub_area_code, options)

Returns the url on craigslist corresponding to the given subdomain, category code, and optionally the code for the sub-location (ie for seattle's eastside neighborhood subdomain would be 'seattle', and sub_area_code would be 'est').

get_posts(next, subdomain, cat_code, sub_area_code, options)

call next() with a list of posts scraped from the url in the format:

  { coords: { latitude: '47.235087', longitude: '-122.351711' },
    pid: '4277229725',
    href: '',
    title: '2 Bedroom/ 1 Bath, Includes W/D, Extra Storage Room, Free Carport',
    date: Tue Dec 31 2013 00:00:00 GMT-0800 (PST),
    price: '785',
    location: 'Fife WA' } ]


Return a list of a cities, optionally matching a specific country/continent