# Download HTML from URLs (`datapilot/download-html-from-urls`) Actor

This script with an Apify Actor to fetch the complete HTML source of any website. The user provides a URL, the page is loaded with JavaScript execution, the full HTML is printed in the terminal, saved to an HTML file,

- **URL**: https://apify.com/datapilot/download-html-from-urls.md
- **Developed by:** [Data Pilot](https://apify.com/datapilot) (community)
- **Categories:** Other
- **Features:** Limited permissions
- **Stats:** 46 total users, 5 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 scraped results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Download HTML from URLs

🚀 **Download HTML from URLs** is a powerful Apify Actor designed to download **HTML content** from any URL using advanced browser automation. This tool captures the full **HTML source code** of web pages, including dynamically loaded content, and provides screenshots for visual reference. Whether you're conducting web scraping research, archiving web pages, or analyzing HTML structures, the Download HTML from URLs delivers comprehensive **HTML data** efficiently.

With browser-based automation, the Download HTML from URLs ensures accurate capture of rendered **HTML** that may not be available through simple HTTP requests. It focuses on key **HTML metrics** like full page source and titles, making it an essential tool for **HTML analysis** and web content extraction.

### 🔥 Features

- **Full HTML Capture** – Downloads complete **HTML source code** from any URL, including JavaScript-rendered content.
- **Browser Automation** – Uses Playwright for headless browser navigation to access fully loaded **HTML pages**.
- **Screenshot Generation** – Captures page previews as PNG images for visual **HTML analysis**.
- **Dynamic Content Handling** – Waits for page loads and JavaScript execution to ensure complete **HTML extraction**.
- **Secure Storage** – Saves **HTML files** and screenshots in Apify's Key-Value Store for easy access.
- **Single URL Processing** – Processes one URL per run for precise **HTML results**.
- **Error Handling** – Robust logging for issues during **HTML downloading**.
- **Dataset Integration** – Automatically uploads **HTML metadata** to your Apify dataset for easy export and analysis.

***

### ⚙️ How It Works

The Download HTML from URLs takes a target URL as input and uses Playwright to launch a headless browser, navigate to the URL, and wait for the page to fully load. It captures the full **HTML source** and takes a screenshot, then saves the HTML and image files to Apify's Key-Value Store while pushing metadata to the dataset. This approach ensures reliable, complete **HTML extraction** from any web page.

**Key Processing Steps:**

1. **URL Validation** – Parse and validate the provided URL
2. **Browser Launch** – Initialize headless Playwright browser
3. **Page Navigation** – Navigate to the target URL
4. **Content Loading** – Wait for full page load and JavaScript execution
5. **HTML Capture** – Extract complete HTML source code
6. **Screenshot** – Capture page preview as PNG image
7. **Secure Storage** – Save files to Key-Value Store
8. **Data Export** – Push metadata to dataset

**Key benefits for HTML analysis:**

- Access full HTML source for web scraping and research.
- Capture dynamic HTML content that requires JavaScript.
- Build HTML archives for content preservation.
- Analyze page structure and metadata.
- Extract rendered HTML content accurately.

***

### 📥 Input

The downloader accepts the following input parameters:

| Field  | Type   | Default  | Description |
|--------|--------|----------|-------------|
| `url`  | string | required | The URL to download HTML from (e.g., `"https://www.example.com"`). |

**Example input JSON:**

```json
{
  "url": "https://www.example.com"
}
```

***

### 📤 Output

The downloader outputs **HTML metadata** in JSON format. Each record includes:

| Field             | Type    | Description |
|-------------------|---------|-------------|
| `url`             | string  | The original URL provided. |
| `title`           | string  | Title of the web page. |
| `html_content`    | string  | Full HTML source code of the page. |
| `html_file_url`   | string  | URL to access FULL_PAGE_SOURCE.html from Key-Value Store. |
| `screenshot_url`  | string  | URL to access PAGE_PREVIEW.png screenshot from Key-Value Store. |
| `page_size`       | integer | Size of HTML file in bytes. |
| `captured_at`     | string  | ISO timestamp of the HTML capture. |
| `status`          | string  | Status of capture (`"Success"` or `"Failed"`). |

**Example output for successful HTML download:**

```json
{
  "url": "https://www.example.com",
  "title": "Example Page Title",
  "html_content": "<!DOCTYPE html><html><head><title>Example Page Title</title>...</head><body>...</body></html>",
  "html_file_url": "https://api.apify.com/v2/key-value-stores/store_id/records/FULL_PAGE_SOURCE.html",
  "screenshot_url": "https://api.apify.com/v2/key-value-stores/store_id/records/PAGE_PREVIEW.png",
  "page_size": 45823,
  "captured_at": "2025-02-14T12:00:00Z",
  "status": "Success"
}
```

**Example error response:**

```json
{
  "url": "https://www.example.com/invalid",
  "status": "Failed",
  "error": "Page not accessible or timeout occurred",
  "captured_at": "2025-02-14T12:00:00Z"
}
```

***

### 🧰 Technical Stack

- **Browser Automation:** Playwright – Fast, headless browser automation
- **Page Interaction:** DOM manipulation and rendering
- **Screenshot Capture:** PNG image generation
- **Storage:** Apify Key-Value Store for secure file storage
- **Platform:** Apify Actor – serverless, scalable, integrated with Dataset and Key‑Value Store
- **Deployment:** One‑click run on Apify Console or via REST API

***

### 🎯 Use Cases

- **Web Scraping Research** – Extract HTML source for web scraping projects and analysis.
- **Web Archiving** – Archive web pages for historical preservation and reference.
- **Content Migration** – Capture HTML for migrating content to other platforms.
- **Competitor Analysis** – Analyze competitor website structures and layouts.
- **SEO Analysis** – Examine HTML structure for SEO optimization.
- **Web Page Backup** – Create backups of important web pages.
- **Legal Compliance** – Archive web pages for legal or compliance purposes.
- **Academic Research** – Collect HTML data for research studies.
- **Website Testing** – Test website HTML before and after changes.
- **Content Analysis** – Analyze page content and structure.
- **Dynamic Content Capture** – Extract JavaScript-rendered content.
- **Meta Data Extraction** – Extract titles, descriptions, and metadata.
- **Accessibility Analysis** – Analyze HTML for accessibility compliance.
- **Performance Research** – Study website code and performance metrics.

***

### 🚀 Quick Start

1. **Open in Apify Console** – visit the Actor page and click Try for free.
2. **Enter a URL** – provide the URL of the web page you want to download HTML from.
3. **Click Start** – the Actor will launch browser, load the page, and capture HTML.
4. **View Results** – check the dataset for HTML metadata and storage links.
5. **Download HTML** – access the full HTML file from the provided URL.
6. **View Screenshot** – see the page preview screenshot.
7. **Export** – download the results as JSON, CSV, or Excel.

You can also call this Actor programmatically via Apify SDK or REST API – ideal for automated web scraping and archiving pipelines.

***

### 💎 Why This Tool?

| Feature | Benefit |
|---------|---------|
| ✅ Full HTML capture | Get complete page source including dynamic content. |
| ✅ Browser automation | Handle JavaScript-rendered pages accurately. |
| ✅ Screenshots included | Get visual preview of captured pages. |
| ✅ Secure storage | Files stored in cloud-based Key-Value Store. |
| ✅ Metadata extraction | Get page titles and structure information. |
| ✅ Error handling | Robust fallback mechanisms for reliability. |
| ✅ Fast processing | Get results quickly with optimized browser settings. |
| ✅ Apify ecosystem | Seamless integration with other Actors, triggers, and webhooks. |

### 📦 Changelog

- Initial release of Download HTML from URLs
- Full HTML source code capture from any URL
- Browser automation with Playwright for dynamic content
- Screenshot generation for visual preview
- Secure Key-Value Store storage for HTML and images
- Complete metadata extraction (titles, page info)
- Error handling with detailed error messages
- Automatic dataset integration
- Full Apify Actor integration

***

### 🧑‍💻 Support & Feedback

- **Issues & Ideas:** Open a ticket on the Apify Actor issue tracker
- **Documentation:** Visit Apify Docs for comprehensive platform guides
- **Community:** Join the Apify community forum for discussions and support
- **Bug Reports:** Submit detailed bug reports through the issue tracker
- **Feature Requests:** Suggest new features to improve the tool

***

### 💰 Pricing

- **Free** for basic usage on Apify platform
- **Paid plans** available for higher limits and priority support
- **Compute credits** consumed for browser automation and processing
- **Storage credits** consumed for HTML and screenshot storage

**Disclaimer:**
Download HTML from URLs is provided as-is for research and archiving purposes. Users are responsible for ensuring their usage complies with website policies and applicable laws. Browser automation may consume significant compute resources.

***

### 🎉 Get Started Today

**Begin downloading HTML from web pages now!**

Use Download HTML from URLs for:

- 🔍 Web Scraping Research
- 📚 Content Archiving
- 🕷️ Web Analysis
- 📊 Competitive Research
- 🔐 Legal Compliance

**Perfect for:**

- Web Developers
- Researchers
- Data Analysts
- SEO Specialists
- Content Archivists

***

**Status:** Active Development\
**Support:** 24/7 Customer Support Available\
**Platform:** Apify

***

### 📚 Related Tools

For comprehensive web analysis and content management, explore our full suite of tools:

- All-in-One Media Downloader
- Ultimate Video Info Fetcher
- Google Search Results Scraper
- Pinterest Pin Video Downloader
- Web Content Analysis Tools

# Actor input Schema

## `url` (type: `string`):

Enter the URL of the website you want to capture.

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

Select proxies to be used by the Actor.

## Actor input object example

```json
{
  "url": "https://www.google.com"
}
```

# 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 = {
    "url": "https://www.google.com"
};

// Run the Actor and wait for it to finish
const run = await client.actor("datapilot/download-html-from-urls").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 = { "url": "https://www.google.com" }

# Run the Actor and wait for it to finish
run = client.actor("datapilot/download-html-from-urls").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 '{
  "url": "https://www.google.com"
}' |
apify call datapilot/download-html-from-urls --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datapilot/download-html-from-urls"
        }
    }
}
```

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/DCMyngtaVyeYrF6he/builds/6UyAOAq9oHwJWRPXj/openapi.json
