# Advanced Yellowpages Scraper (`dainty_screw/advanced-yellowpages-scraper`) Actor

Yellowpages Scraper is a robust tool designed to scrape business information from Yellowpages. It efficiently extracts essential details such as business names, addresses, phone numbers, categories, and more.

- **URL**: https://apify.com/dainty_screw/advanced-yellowpages-scraper.md
- **Developed by:** [codemaster devops](https://apify.com/dainty_screw) (community)
- **Categories:** Lead generation, Automation
- **Features:** Full permissions
- **Stats:** 141 total users, 1 monthly users, 100.0% runs succeeded, 11 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.50 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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) designed for scraping information from Yellow Pages listings. It allows you to search records based on a combination of search terms and location or a list of URLs. Built on top of the [Apify SDK](https://sdk.apify.com/), it can be run both on the [Apify platform](https://my.apify.com) and locally.

### Table of Contents

- [Input](#input)
- [Output](#output)
- [Compute Units Consumption](#compute-units-consumption)
- [Extend Output Function](#extend-output-function)
- [Contact](#contact)

### Input

| Field | Type | Description | Default Value |
| ----- | ---- | ----------- | ------------- |
| site | string | Country/site key to target the correct Yellow Pages domain (e.g. `us`, `ghana`, `nigeria`, `kenya`, `uganda`) | `"us"` |
| 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. URLs may be absolute or relative to the configured site | none |
| siteConfig | object | Advanced overrides for `baseUrl`, `searchUrlTemplate`, or CSS selectors when targeting unsupported domains | 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 {}; }` |
| proxyConfiguration | object | Proxy settings of the run. If you have access to Apify proxy, you can set `{ "useApifyProxy": true }` to enable proxy usage | `{ "useApifyProxy": false }` |

Either the `search` and `location` attributes or the `startUrls` attribute must be set.

#### Multi-site support

Set `site` to one of the supported shortcuts to automatically adjust the base domain and default selectors. If the regional Yellow Pages instance uses different markup, provide a `siteConfig` object with custom selectors or `searchUrlTemplate`, or fall back to explicit `startUrls`.

Currently bundled shortcuts: `us`, `ghana`, `nigeria`, `kenya`, `uganda`.

| Site key | Base domain(s) | Notes |
| -------- | -------------- | ----- |
| `us` | `https://www.yellowpages.com` (also `https://www.yp.com`) | Honour a ~5 s crawl delay; listings use `.result` cards and classic pagination. |
| `ghana` | `https://ghanayellowpages.com` | WordPress-style listings in `ul.results-list`; low-volume site—throttle to ≤1 rps. |
| `nigeria` | `https://yellowpagesnigeria.com` | Mixed templates (`.listing`, `.result`, `article`); selectors fallback across variants. |
| `kenya` | `https://yellow.co.ke` | Uses “Load more” buttons; follow the link exposed in `a.load-more` to paginate. |
| `uganda` | `https://yellowpagesuganda.com` | Service is unstable (frequent 5xx). Treat as best-effort and consider providing `startUrls`. |

> Tip: respect each site’s `robots.txt` and Terms. Smaller directories react badly to high concurrency—stick to 1 request/second unless you know they can handle more.

### Output

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

```json
{
    "name": "The Modern NYC",
    "address": "9 W 53rd St, New York, NY 10019",
    "phone": "(212) 333-1220",
    "website": "https://www.themodernnyc.com",
    "rating": 4.7,
    "reviewSnippet": "A phenomenal dining experience with exquisite food and service. The best modern cuisine in NYC!",
    "categories": [
        "Restaurants",
        "Fine Dining",
        "American Cuisine"
    ],
    "url": "https://www.yelp.com/biz/the-modern-new-york"
}

```

Please note that not all attributes will be present in all results.

### Compute Units Consumption

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

The average consumption is about **0.04 Compute Units per 2000 results** scraped.

### Extend Output Function

You can use this function to customize the default output of this actor. This function takes a Cheerio object and a Cheerio representation of the record element ($, record) as arguments, allowing you to add or modify attributes as needed. The output from this function will be merged with the default output.

The return value of this function must be an object!

You can return fields to achieve three different things:

- **Add a new field**: Return an object with a field that is not in the default output.
- **Change a field**: Return an existing field with a new value.
- **Remove a field**: Return an existing field with a value of `undefined`.

```javascript
($, record) => {
    return {
        directionsLink: record.find('.directions').attr('href'),
        rating: 5,
        phone: undefined,
    }
}
```

This example will add a new field `directionsLink`, change the `rating` field, and remove the `phone` field.

### Contact

For any questions or support, please contact us at [support@example.com](mailto:contact@quicklifesolutions.com).

***

**Connect With Us**

- **YouTube**: [Visit our channel](https://www.youtube.com/@quicklifesolutions)
- **Instagram**: [Follow us on Instagram](https://www.instagram.com/quicklifesolutionsofficial/)
- **AI Newsletter**: [Subscribe to our newsletter](https://sendfox.com/quicklifesolutions)
- **Free Consultation**: [Book a free consultation call](https://tidycal.com/quicklifesolutions/free-consultation)
- **More Tools**: [Explore our Apify actors](https://apify.com/dainty_screw)
- **Discord**: [Raise a Support ticket here](https://discord.gg/2WGj2PDmHb)
- **Contact Email**: <codemasterdevops@gmail.com>

# Changelog

This Actor's version history is a separate document: https://apify.com/dainty_screw/advanced-yellowpages-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

## `extendOutputFunction` (type: `string`):

A function which result will get merged with the default result

## `proxyConfiguration` (type: `object`):

In this case the best option is usually no proxy. Otherwise US or UK proxies work best.

## `site` (type: `string`):

Site or country to target (e.g. us, ghana, nigeria, kenya, uganda).

## `siteConfig` (type: `object`):

Advanced overrides for baseUrl, searchUrlTemplate or selectors when targeting bespoke Yellow Pages deployments.

## Actor input object example

```json
{
  "search": "Dentist",
  "location": "Los Angeles",
  "maxItems": 200,
  "extendOutputFunction": "($, record) => {\n    return {};\n}",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "site": "us"
}
```

# 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": 200,
    "extendOutputFunction": ($, record) => {
        return {};
    },
    "proxyConfiguration": {
        "useApifyProxy": false
    },
    "site": "us"
};

// Run the Actor and wait for it to finish
const run = await client.actor("dainty_screw/advanced-yellowpages-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": 200,
    "extendOutputFunction": """($, record) => {
    return {};
}""",
    "proxyConfiguration": { "useApifyProxy": False },
    "site": "us",
}

# Run the Actor and wait for it to finish
run = client.actor("dainty_screw/advanced-yellowpages-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": 200,
  "extendOutputFunction": "($, record) => {\\n    return {};\\n}",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "site": "us"
}' |
apify call dainty_screw/advanced-yellowpages-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dainty_screw/advanced-yellowpages-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/WY7Te6MZqaO5pUMkK/builds/ArCgkgZbSro2pwwec/openapi.json
