
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 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 :
Continue reading on Dev.to Tutorial
Opens in a new tab



