DEV Community

Алексей Спинов
Алексей Спинов

Posted on

How to Scrape Craigslist Listings (Cars, Housing, Jobs) with Node.js

Craigslist is still one of the most scraped sites. Here is how to do it right.

Craigslist RSS Feeds (Easiest)

Craigslist has RSS feeds for every search:

https://sfbay.craigslist.org/search/apa?format=rss&query=studio
https://sfbay.craigslist.org/search/sss?format=rss&query=macbook
https://sfbay.craigslist.org/search/jjj?format=rss&query=developer
Enter fullscreen mode Exit fullscreen mode

Category codes:

  • apa = apartments
  • sss = for sale
  • jjj = jobs
  • cto = cars

Parse RSS with Node.js

const { parseStringPromise } = require("xml2js");

async function getCraigslistListings(city, category, query) {
  const url = `https://${city}.craigslist.org/search/${category}?format=rss&query=${encodeURIComponent(query)}`;
  const res = await fetch(url);
  const xml = await res.text();
  const parsed = await parseStringPromise(xml);

  return (parsed.rdf?.item || []).map(item => ({
    title: item.title?.[0],
    link: item.link?.[0],
    description: item.description?.[0]?.replace(/<[^>]+>/g, ""),
    date: item["dc:date"]?.[0]
  }));
}

const apartments = await getCraigslistListings("sfbay", "apa", "studio");
console.table(apartments);
Enter fullscreen mode Exit fullscreen mode

Use Cases

  • Housing market research — track rental prices by area
  • Car pricing — find deals on specific makes/models
  • Job market — salary and demand analysis
  • Product resale — find underpriced items

Resources


Need Craigslist data extracted? $20. Any city, any category. Email: Spinov001@gmail.com | Hire me

Top comments (0)