DEV Community

Ava Torres
Ava Torres

Posted on

Automate YellowPages Business Lead Extraction to Google Sheets with n8n and Apify

The Problem

You need local business leads — names, phone numbers, addresses, emails — from YellowPages. Copying them manually is slow. Most scraping tools break when YP changes their layout.

The Solution

A 4-node n8n workflow that:

  1. Runs a YellowPages scraper on Apify
  2. Waits for results
  3. Pipes structured lead data into Google Sheets

Total cost: ~$0.002 per lead. A 50-lead run costs $0.10.

Prerequisites

  • n8n instance (cloud or self-hosted)
  • Apify account (free tier works for testing)
  • Google Sheets credentials in n8n
  • Install the @apify/n8n-nodes-apify community node in n8n

The Workflow

Node 1: Manual Trigger

Start with a manual trigger so you can test the workflow before scheduling it.

Node 2: Run YellowPages Scraper

Use the Apify node to run pink_comic/yellowpages-scraper:

{
  "searchTerms": ["plumbers"],
  "locations": ["San Francisco, CA"],
  "maxResults": 50,
  "includeDetails": true
}
Enter fullscreen mode Exit fullscreen mode

Key parameters:

  • searchTerms: Array of business categories to search
  • locations: Array of cities/states
  • maxResults: Cap the number of results to control costs
  • includeDetails: Set to true to extract emails, hours, and payment methods from each business detail page

Set waitForFinish to 300 seconds so the node waits for the scraper to complete.

Node 3: Get Results

HTTP Request node to fetch the dataset:

GET https://api.apify.com/v2/datasets/{{ $json.defaultDatasetId }}/items?format=json
Enter fullscreen mode Exit fullscreen mode

This returns an array of lead objects with fields like:

  • name — Business name
  • phone — Primary phone number
  • address, city, state, zip — Full address
  • email — Extracted from the business detail page
  • website — Business website URL
  • rating, reviewCount — YellowPages ratings
  • hours — Operating hours
  • categories — Business categories

Node 4: Append to Google Sheets

Use the Google Sheets node with autoMapInputData to push all fields into your spreadsheet. Each lead becomes a row.

Scheduling It

Replace the Manual Trigger with a Schedule Trigger to run weekly or daily. Example: run every Monday at 9am to refresh your lead list.

Cost Breakdown

Leads Cost
50 $0.10
200 $0.40
1,000 $2.00

The includeDetails option adds ~2 seconds per lead (detail page visit) but is worth it for the email extraction.

Workflow JSON

Import this directly into n8n:

{
  "name": "YellowPages Business Leads to Google Sheets",
  "nodes": [
    {
      "parameters": {},
      "id": "start-node",
      "name": "When clicking Test workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "actorId": "pink_comic/yellowpages-scraper",
        "input": "{\n  \"searchTerms\": [\"plumbers\"],\n  \"locations\": [\"San Francisco, CA\"],\n  \"maxResults\": 50,\n  \"includeDetails\": true\n}",
        "options": {
          "memoryMbytes": 256,
          "timeoutSecs": 300,
          "waitForFinish": 300
        }
      },
      "id": "run-actor",
      "name": "Run YellowPages Scraper",
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [460, 300]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/datasets/{{ $json.defaultDatasetId }}/items?format=json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "options": {}
      },
      "id": "get-results",
      "name": "Get Lead Results",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "columns": {
          "mappingMode": "autoMapInputData"
        },
        "options": {}
      },
      "id": "sheets-node",
      "name": "Append to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [900, 300]
    }
  ],
  "connections": {
    "When clicking Test workflow": {
      "main": [[{"node": "Run YellowPages Scraper", "type": "main", "index": 0}]]
    },
    "Run YellowPages Scraper": {
      "main": [[{"node": "Get Lead Results", "type": "main", "index": 0}]]
    },
    "Get Lead Results": {
      "main": [[{"node": "Append to Google Sheets", "type": "main", "index": 0}]]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Other Actors You Can Swap In

The same workflow pattern works with any Apify actor. Some useful ones for lead generation:

All cost $0.002/result with pay-per-result pricing.


Questions? Drop a comment.

Top comments (0)