# Yellow Pages US Scraper (`trudax/yellow-pages-us-scraper`) Actor

Scrape addresses, phone numbers, categories, and names from Yellow Pages US listings. Customizable Yellow Pages API to crawl and download all contact data.

- **URL**: https://apify.com/trudax/yellow-pages-us-scraper.md
- **Developed by:** [Trudax](https://apify.com/trudax) (community)
- **Categories:** Lead generation
- **Stats:** 4,975 total users, 65 monthly users, 81.5% runs succeeded, 59 bookmarks
- **User rating**: 3.80 out of 5 stars

## Pricing

Pay per event

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

#### Yellow Pages Scraper

Yellow Pages Scraper is an [Apify actor](https://apify.com/actors) for scraping information from Yellow Pages listings. It allows you to search records based on a combination of search term and location or a list of URLs. It is build on top of [Apify SDK](https://sdk.apify.com/) and you can run it both on [Apify platform](https://my.apify.com) and locally.

- [Features](#features)
- [What Data Can You Extract](#what-data-can-you-extract)
- [Usage and Cost](#usage-and-cost)
- [Getting Started](#getting-started)
- [Input](#input)
- [Output](#output)

#### Features

Yellow Pages Scraper empowers you to:

- **Scrape Yellow Pages Listings**: Extract detailed information from Yellow Pages listings.
- **Search by Term and Location**: Customize your search by specifying search terms and locations.
- **Deep Crawling**: Scrape data from Yellow Pages record list pages.
- **Proxy Support**: Use Apify Proxy for efficient scraping.

#### What Data Can You Extract?

Yellow Pages Scraper allows you to extract a variety of data from Yellow Pages listings, including:

- Business Name
- Address
- Phone Number
- Ratings and Review Counts
- Additional Information Snippets
- Images
- Categories

Please note that the availability of these attributes may vary based on the data source.

#### Usage and Cost

Keep in mind that it is much more efficient to run one longer scrape (at least one minute) than more shorter ones because of the startup time.

The average consumption is about **0.04 Compute unit per 2000 results** scraped.
Running Yellow Pages Scraper on the [Apify platform](https://my.apify.com) offers great value. For pricing details and cost estimates, refer to the [Apify pricing page](https://apify.com/pricing).

#### Getting Started

Using Yellow Pages Scraper is easy and doesn't require coding skills. Here's a quick guide:

1. Create a [free Apify account](https://my.apify.com) using your email.
2. Access the [Yellow Pages Scraper](YOUR_ACTOR_LINK).
3. Configure your search terms, locations, and other parameters.
4. Click "Start" and let the scraper do its job.
5. Download the scraped data in JSON, XML, CSV, Excel, or HTML format.

#### Input

| Field | Type | Description | Default value
| ----- | ---- | ----------- | -------------|
| search | string | Query string to be searched on the site | `"Dentist"` |
| location | string | Location string to search the records in | `"Los Angeles"` |
| startUrls | array | List of [Request](https://sdk.apify.com/docs/api/request#docsNav) objects that will be deeply crawled. The URL can be any Yellowpages.com record list page | none |
| maxItems | number | Maximum number of pages that will be scraped | `200` |
| extendOutputFunction | string | Function that takes a Cheerio object and a Cheerio representation of the record element ($, record) as arguments and returns data that will be merged with the default output. More information in [Extend output function](#extend-output-function) | `($, record) => { return {}; }` |

Either the `search` and `location` attributes or the `startUrls` atrribute has to be set.

#### Output

Output is stored in a dataset. Each item is information about a record.

```
{
  "isAd": true,
  "url": "https://www.yellowpages.com/compton-ca/mip/golden-state-dental-group-18768214?lid=1001760866489",
  "name": "Golden State Dental Group",
  "address": "1601 N Long Beach Blvd, Compton, CA 90221",
  "phone": "(310) 507-7718",
  "rating": 4,
  "ratingCount": 6,
  "infoSnippet": "*Please contact us for more information",
  "image": "https://i4.ypcdn.com/blob/00a40d49e577606be9d82ced5404696022a7e2a0",
  "categories": [
    "Dentists",
    "Implant Dentistry",
    "Pediatric Dentistry",
    "Periodontists",
    "Cosmetic Dentistry"
  ]
}
```

Please note that not all of the attributes will be present with all the results.

# Actor input Schema

## `search` (type: `string`):

Query to search on Yellow Pages

## `location` (type: `string`):

Location to search entries in

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

List of URLs that will be crawled.

## `maxItems` (type: `integer`):

Maximum number of outputted results

## `debugMode` (type: `boolean`):

Activate to see detailed logs

## Actor input object example

```json
{
  "search": "Dentist",
  "location": "Los Angeles",
  "maxItems": 10,
  "debugMode": false
}
```

# 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 = {
    "search": "Dentist",
    "location": "Los Angeles",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("trudax/yellow-pages-us-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 = {
    "search": "Dentist",
    "location": "Los Angeles",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("trudax/yellow-pages-us-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "search": "Dentist",
  "location": "Los Angeles",
  "maxItems": 10
}' |
apify call trudax/yellow-pages-us-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=trudax/yellow-pages-us-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/wWqrTazDTGHCGTFvw/builds/FS3uEsGQcdTwfr1dn/openapi.json
