```yaml
product: AlterLab
title: "How to Extract Email Addresses from a Website | AlterLab | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/how-to/extract-emails-from-website
```

Beginner4 steps

# How to Extract Email Addresses from a Website

Finding publicly listed contact email addresses across multiple pages of a website requires fetching each page and applying pattern matching. Doing this at scale means handling pagination, varying page structures, and consistent data delivery.

## Step-by-Step Guide

1

### Fetch the target page

Send the URL to the AlterLab API to retrieve the full HTML content, including any dynamically loaded contact sections.

2

### Apply regex pattern matching

Use a standard email regex pattern to extract all email addresses from the returned HTML. Filter out common no-reply or placeholder addresses as needed.

3

### Deduplicate and validate results

Remove duplicates and validate the format of extracted addresses before storing them.

4

### Crawl additional pages

Repeat the process for contact, about, and team pages on the same domain to maximize coverage.

## Code Example

Python

```
import requests
import re

def extract_emails(url: str, api_key: str) -> list[str]:
    response = requests.post(
        "https://alterlab.io/api/v1/scrape",
        headers={"X-API-Key": api_key, "Content-Type": "application/json"},
        json={"url": url},
    )
    html = response.json().get("html", "")
    pattern = r'[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}'
    return list(set(re.findall(pattern, html)))

emails = extract_emails("https://example.com/contact", "YOUR_API_KEY")
print(emails)
```

Replace `YOUR_API_KEY` with your key from the . No credit card required.

## Try this yourself with AlterLab

Run this tutorial on live websites with AlterLab's API. New accounts get up to 5,000 free requests — no credit card required.

[View API docs](https://alterlab.io/docs/api/rest)

## Frequently Asked Questions

### Can I extract emails that are only visible after JavaScript loads?

Yes — set `render_js: "auto"` in your request to execute JavaScript before extraction. This reveals emails loaded via contact forms or dynamic content blocks.

### Is extracting publicly listed emails legal?

Extracting publicly listed contact information may vary in legality by jurisdiction. Always review the target website's terms of service and comply with applicable data protection regulations such as GDPR in your jurisdiction.

### Responsible Use

AlterLab is designed for extracting publicly available data. Always review the terms of service for any website you access, respect `robots.txt` directives, and ensure your use case complies with applicable laws in your jurisdiction.

### More tutorials

Browse all [how-to guides](https://alterlab.io/how-to) for web scraping — from beginner extractions to advanced multi-page pipelines.

## Your first scrape. Sixty seconds.

Up to 5,000 free requests — about 5,000 Light, 500 Protected or 250 Dynamic requests. No credit card. 
Just a POST request.

terminal

curl -X POST https://api.alterlab.io/v1/scrape \

-H "X-API-Key: YOUR_KEY" \

-H "Content-Type: application/json" \

-d '{"url": "https://example.com", "formats": ["markdown"]}'

[Start building free](https://alterlab.io/signin)

No credit card required · Up to 5,000 free requests (about 5,000 Light, 500 Protected or 250 Dynamic requests) · Balance never expires