# Craigslist Scraper (`leonardparisi/craigslist-scraper`) Actor

Scrapes Craigslist search results via HTML parsing with stealth browser.

- **URL**: https://apify.com/leonardparisi/craigslist-scraper.md
- **Developed by:** [Leonard Parisi](https://apify.com/leonardparisi) (community)
- **Categories:** Automation, Lead generation
- **Stats:** 3 total users, 2 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Craigslist Scraper (Apify Actor)

Custom Apify actor that scrapes Craigslist search results via HTML parsing in a stealth browser. Extracts listing title, price, location, post date, image, and direct URL from any Craigslist search page.

### How it works

Uses `PlaywrightCrawler` (Crawlee) with Apify residential proxies (`RESIDENTIAL`, `US`). Navigates to the provided search URL, waits for `li.cl-static-search-result` elements in the DOM, and extracts listing data via `page.$$eval`. Images and fonts are blocked to reduce proxy bandwidth.

### Input

```json
{
  "startUrls": [
    { "url": "https://sfbay.craigslist.org/search/sss?query=bike&postal=94102&search_distance=25" }
  ],
  "resultsLimit": 20
}
```

| Field | Type | Default | Max |
|---|---|---|---|
| `startUrls` | array of `{ url }` | required | — |
| `resultsLimit` | integer | 20 | 120 |

Any Craigslist search URL works: use the `postal` and `search_distance` query params to scope by zip code and radius. The `sss` category searches all for-sale listings.

### Output

Each run pushes an array of objects to the Apify dataset:

```json
{
  "searchUrl": "https://sfbay.craigslist.org/search/sss?query=bike&postal=94102&search_distance=25",
  "listingId": "7925863090",
  "title": "Trek Road Bike",
  "url": "https://sfbay.craigslist.org/sfc/bik/d/san-francisco-trek-road-bike/7925863090.html",
  "price": "$350",
  "location": "mission district",
  "postedAt": "2024-01-15T10:30:00-0800",
  "imageUrl": "https://images.craigslist.org/00L0L_xxxxx.jpg"
}
```

`price`, `location`, `postedAt`, and `imageUrl` are `null` when not present on the listing card.

If no listings are collected, a debug HTML snapshot is saved to the actor key-value store.

### Development

```bash
npm install       # install deps + generate package-lock.json (commit this)
npm run build     # tsc → dist/
```

### Deployment

`apify-cli` is a local dev dependency — no global install needed.

```bash
## First time only
./node_modules/.bin/apify login

## Build + push in one step
npm run deploy
```

After pushing, copy the actor ID from the Apify console (`your-username~craigslist-scraper`) and update `ACTOR_ID` in `apps/api/src/adapters/craigslist.ts`.

### Infrastructure

- **Base image:** `apify/actor-node-playwright-chrome` pinned to digest in `Dockerfile`
- **Proxies:** Apify residential pool, US only — requires an Apify plan with residential proxy access
- **Memory:** 1024 MB minimum (Playwright + Chrome)
- **Runtime:** Node 20, ESM (`"type": "module"`)

# Actor input Schema

## `startUrls` (type: `array`):

List of Craigslist search URLs to scrape (e.g. https://sfbay.craigslist.org/search/sss?query=bike\&postal=94102\&search_distance=25).

## `resultsLimit` (type: `integer`):

Maximum number of listings to return per URL.

## Actor input object example

```json
{
  "resultsLimit": 20
}
```

# Actor output Schema

## `listings` (type: `string`):

Dataset of normalized Craigslist listings.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("leonardparisi/craigslist-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("leonardparisi/craigslist-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call leonardparisi/craigslist-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,leonardparisi/craigslist-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/4zNjmcAd0Ih9pVtae/builds/QSg9RdSon2MysPXgQ/openapi.json
