# Email Scraper (`ib4ngz/email-scraper`) Actor

This actor scrapes email addresses from a list of provided URLs. It recursively crawls pages, extracts unique emails, and stores them in a dataset. The actor supports DNS validation to ensure domain authenticity and allows filtering based on custom crawling depth.

- **URL**: https://apify.com/ib4ngz/email-scraper.md
- **Developed by:** [Iqbal R](https://apify.com/ib4ngz) (community)
- **Categories:** Automation, Developer tools, SEO tools
- **Features:** Limited permissions
- **Stats:** 695 total users, 25 monthly users, 100.0% runs succeeded, 9 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.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

## Email Scraper

This actor scrapes email addresses from a list of provided URLs. It recursively crawls pages, extracts unique email addresses, and stores them in a dataset. The actor supports DNS validation to ensure domain authenticity and allows filtering based on custom crawling depth. Only unique email addresses are saved, preventing duplicates during the scraping process.

### Features

- **Email Extraction**: Extracts email addresses from a list of provided URLs and recursively explores linked pages to gather additional emails.
- **Recursive Crawling**: Crawls web pages to a user-defined maximum depth, enabling thorough exploration while managing resource usage.
- **DNS Validation**: Validates email domains using MX records and falls back to DNS-over-HTTPS when the system DNS resolver is unavailable. Domains with no MX or an explicit null MX are excluded.
- **Unique Dataset**: Ensures only unique email addresses are saved by preventing duplicates during the crawling process.

### Input Schema

- **Start URLs** (required): A list of URLs to start crawling from.
- **Maximum Depth**: The maximum depth for crawling, defining how deep the crawler should explore.
- **DNS Lookup**: Option to enable or disable DNS validation for email domains.
- **Proxy Configuration**: Configuration settings for selecting and using proxies during crawling.
- **Minimum Concurrency**: The minimum number of concurrent requests or pages to process.
- **Maximum Concurrency**: The maximum number of concurrent requests or pages to process.

When DNS lookup is enabled, the Actor first uses the system DNS resolver. If that resolver fails, it retries through Cloudflare DNS-over-HTTPS. Set the `DNS_OVER_HTTPS_URL` environment variable to use another compatible JSON DNS endpoint.

### Dataset Schema

- **email**: The extracted email address.
- **dnsLookup**: Indicates whether the email domain passed DNS validation.

### How to Use

1. **Set up the Actor**\
   Start by providing a list of URLs to begin the crawling process. You can either manually input the URLs or provide a list in the actor configuration.

2. **Configure the Input Parameters**

   - **Start URLs**: Provide the initial URLs from which the crawler will start.
   - **Maximum Depth**: Define how deep the crawler should explore.
   - **DNS Lookup**: Choose whether to validate email domains using DNS records.
   - **Proxy Configuration**: If necessary, configure the proxy settings for your crawler.
   - **Concurrency**: Adjust the minimum and maximum concurrency based on your needs.

3. **Run the Actor**\
   Once the input parameters are configured, run the actor to start the crawling process. The actor will crawl the pages, extract unique email addresses, and store the results in the dataset.

4. **View Results**\
   After the actor finishes running, you can view the extracted email addresses in the dataset. The data will be displayed in a table format with the following fields:

   - Email Address
   - DNS Lookup Status

5. **Export Data**\
   You can export the dataset for further processing or analysis. The results are saved in a structured format for easy integration with other tools.

6. **Modify Parameters**\
   Adjust the configuration and rerun the actor as needed to gather additional data or refine the crawling process.

### Conclusion

This actor provides an efficient solution for scraping and extracting unique email addresses from a list of URLs. It recursively crawls the provided pages, extracts emails, and stores them in a dataset. By respecting a defined maximum depth and supporting DNS validation, it ensures only authentic and relevant emails are captured.

The actor is optimized to prevent duplicates by saving only unique email addresses during the crawling process. This makes it a valuable tool for anyone looking to gather email data in a structured and efficient manner, while maintaining control over the types of emails collected.

# Actor input Schema

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

URLs to start with.

## `maxDepth` (type: `integer`):

The maximum depth for crawling.

## `dnsLookup` (type: `boolean`):

Enable or disable DNS lookup validation for email domains.

## `crawlerType` (type: `string`):

Select the type of crawler to use.

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

Select proxies to be used by your crawler.

## `minConcurrency` (type: `integer`):

The minimum number of concurrent requests or pages being processed.

## `maxConcurrency` (type: `integer`):

The maximum number of concurrent requests or pages being processed.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://apify.com/contact"
    }
  ],
  "maxDepth": 1,
  "dnsLookup": true,
  "crawlerType": "Crawlee + Cheerio",
  "minConcurrency": 1,
  "maxConcurrency": 1
}
```

# 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 = {
    "startUrls": [
        {
            "url": "https://apify.com/contact"
        }
    ],
    "maxDepth": 1,
    "dnsLookup": true,
    "crawlerType": "Crawlee + Cheerio",
    "minConcurrency": 1,
    "maxConcurrency": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("ib4ngz/email-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 = {
    "startUrls": [{ "url": "https://apify.com/contact" }],
    "maxDepth": 1,
    "dnsLookup": True,
    "crawlerType": "Crawlee + Cheerio",
    "minConcurrency": 1,
    "maxConcurrency": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("ib4ngz/email-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 '{
  "startUrls": [
    {
      "url": "https://apify.com/contact"
    }
  ],
  "maxDepth": 1,
  "dnsLookup": true,
  "crawlerType": "Crawlee + Cheerio",
  "minConcurrency": 1,
  "maxConcurrency": 1
}' |
apify call ib4ngz/email-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ib4ngz/email-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/XGjxXt04VZlDrjgKz/builds/r23JS7FHdEl1swC0p/openapi.json
