# 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:** 5,042 total users, 24 monthly users, 36.0% runs succeeded, 59 bookmarks
- **User rating**: 3.80 out of 5 stars

## Pricing

from $3.00 / 1,000 result storeds

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

#### 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.

# Changelog

This Actor's version history is a separate document: https://apify.com/trudax/yellow-pages-us-scraper/changelog.md

# 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(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 '{
  "search": "Dentist",
  "location": "Los Angeles",
  "maxItems": 10
}' |
apify call trudax/yellow-pages-us-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,trudax/yellow-pages-us-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/wWqrTazDTGHCGTFvw/builds/IvNnTtDXChChi2Lcd/openapi.json
