> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Advanced Scraping Guide

> Every page option for Scrape, and for the pages of Search and Crawl

This guide covers the page options of ScreenshotRender. They work on `/scrape`. [Search](/features/search.md) and [Crawl](/features/crawl.md) take them in `scrapeOptions`, for every page they read.

Every example below was run against the API. Each one costs 1 credit, the price of a page.

## Basic scraping

Send a URL and the formats you want. See [Scrape](/features/scrape.md) for every format.

```json
{
  "url": "https://example.com",
  "formats": ["markdown"]
}
```

## Main content only

By default, `onlyMainContent` is `true` and leaves out parts of the page around its main content, such as the site header. Set it to `false` to get the whole page.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.python.org/3/tutorial/introduction.html",
    "formats": ["markdown"],
    "onlyMainContent": false
  }'
```

On this page, the whole page is 26,712 characters of Markdown, and the default 23,681.

## Include and exclude tags

`includeTags` keeps only the elements that match these tags or CSS selectors. `excludeTags` drops the ones that match.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.python.org/3/tutorial/introduction.html",
    "formats": ["markdown"],
    "includeTags": ["h1", "h2", "p"],
    "excludeTags": ["#sidebar", ".footer"]
  }'
```

## Wait and timeout

`waitFor` waits this many milliseconds after the page loads, for content that comes late. `timeout` is the most milliseconds to wait for the page.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.screenshotrender.com",
    "formats": ["markdown"],
    "waitFor": 2000,
    "timeout": 30000
  }'
```

## Location and language

`location.country` loads the page from a country (ISO code), and `location.languages` sets the languages the browser asks for. This request gets Google's German home page.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.google.com",
    "formats": ["markdown"],
    "location": { "country": "DE", "languages": ["de-DE"] }
  }'
```

## Mobile, ads and cookie banners

`mobile` loads the page as a phone would. `blockAds` hides ads and cookie banners.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.screenshotrender.com",
    "formats": ["screenshot"],
    "mobile": true,
    "blockAds": true,
    "waitFor": 1000,
    "location": { "country": "US" }
  }'
```

## Cache and max age

A page can come from a recent copy: its metadata then has `cacheState: "hit"` and `cachedAt`, when the copy was made. Set `maxAge` to the oldest copy you accept, in milliseconds. `0` always loads the page fresh.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "formats": ["markdown"],
    "maxAge": 0
  }'
```

## Headers

`headers` sends your own HTTP headers with the request, like a cookie or a custom header.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://httpbin.org/headers",
    "formats": ["markdown"],
    "headers": { "X-Docs-Example": "hello" },
    "maxAge": 0
  }'
```

The page above echoes the headers it received, so its Markdown contains `X-Docs-Example: hello`.

## Actions

`actions` run on the page, in order, before it is read.

| Action | Fields | What it does |
| - | - | - |
| `wait` | `milliseconds` | Waits this long. |
| `click` | `selector` | Clicks the first element that matches the CSS selector. |
| `screenshot` | | Takes a screenshot at this point. Its link is added to `data.actions.screenshots`. |

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.python.org/3/",
    "formats": ["markdown"],
    "actions": [
      { "type": "wait", "milliseconds": 1000 },
      { "type": "click", "selector": "a[href=\"tutorial/index.html\"]" },
      { "type": "wait", "milliseconds": 1000 },
      { "type": "screenshot" }
    ]
  }'
```

```json Response
{
  "success": true,
  "data": {
    "markdown": "### Navigation\n\n- [index](https://docs.python.org/3/genindex.html \"General Index\")\n- [modules](https://docs.python.org/3/py-modindex.html \"Python Module Index\")...",
    "actions": {
      "screenshots": [
        "https://www.screenshotrender.com/files/screenshots/yqQzq-6RCimYa79f9K_tiyJ6vD2cC5No.png"
      ],
      "scrapes": [],
      "javascriptReturns": [],
      "pdfs": []
    },
    "metadata": {
      "title": "The Python Tutorial — Python 3.15.2 documentation",
      "description": "Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but...",
      "language": "en",
      "sourceURL": "https://docs.python.org/3/",
      "url": "https://docs.python.org/3/tutorial/index.html",
      "statusCode": 200,
      "contentType": "text/html",
      "proxyUsed": "basic"
    }
  },
  "creditsUsed": 1
}
```

This request opens the Python docs, clicks the link to the tutorial, and takes a screenshot of the tutorial page.

## Page options reference

| Option | Type | Default | Description |
| - | - | - | - |
| `formats` | array | `["markdown"]` | The formats to return. See [Scrape formats](/features/scrape.md#scrape-formats). |
| `onlyMainContent` | boolean | `true` | Leave out the parts of the page around its main content. |
| `includeTags` | array | | Keep only elements matching these tags or selectors. |
| `excludeTags` | array | | Drop elements matching these tags or selectors. |
| `waitFor` | number | | Milliseconds to wait after the page loads. |
| `timeout` | number | | Most milliseconds to wait for the page. |
| `mobile` | boolean | | Load the page as a phone would. |
| `blockAds` | boolean | | Hide ads and cookie banners. |
| `location` | object | | `country` (ISO code) and `languages`. |
| `maxAge` | number | | Oldest cached copy to accept, in milliseconds. `0` loads the page fresh. |
| `headers` | object | | HTTP headers to send with the request. |
| `actions` | array | | Actions to run before the page is read. |
