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

# scrape

<Tip>
  Read [the Notte skill](https://notte.cc/skill.md) and follow its setup instructions when setting up Notte or building browser automation. This is the shared source for CLI setup, authentication, and the browser-to-code workflow.
</Tip>

[Source: node-sdk/src/session.ts](https://github.com/nottelabs/notte/blob/main/node-sdk/src/session.ts)

Scrape the current page.

With `response_format` or `instructions`, the extracted data is returned
directly and a failed extraction throws `ScrapeFailedError`. Pass
`raiseOnFailure: false` to receive the `StructuredData` wrapper instead.

```typescript theme={null}
Session.scrape(options: SessionScrapeOptions<unknown> & { only_images: true; }): Promise<ImageData[]>;
Session.scrape(options?: SessionScrapeOptions<unknown> & { response_format?: undefined; instructions?: undefined | null; only_images?: false; }): Promise<string>;
Session.scrape<T>(options: SessionScrapeOptions<T> & { response_format: ZodLikeSchema<T>; raiseOnFailure?: true; }): Promise<T>;
Session.scrape<T>(options: SessionScrapeOptions<T> & { response_format: ZodLikeSchema<T>; raiseOnFailure: false; }): Promise<StructuredData<T>>;
Session.scrape(options: SessionScrapeOptions<unknown>): Promise<ScrapeResult<unknown>>;
```

## Parameters (overload 1)

<ParamField body="options" type={"SessionScrapeOptions<unknown> & { only_images: true }"} required />

## Returns (overload 1)

```typescript theme={null}
Promise<ImageData[]>
```

## Parameters (overload 2)

<ParamField body="options" type={"SessionScrapeOptions<unknown> & { response_format?: undefined; instructions?: undefined | null; only_images?: false }"} />

## Returns (overload 2)

```typescript theme={null}
Promise<string>
```

## Parameters (overload 3)

<ParamField body="options" type={"SessionScrapeOptions<T> & { response_format: ZodLikeSchema<T>; raiseOnFailure?: true }"} required />

## Returns (overload 3)

```typescript theme={null}
Promise<T>
```

## Parameters (overload 4)

<ParamField body="options" type={"SessionScrapeOptions<T> & { response_format: ZodLikeSchema<T>; raiseOnFailure: false }"} required />

## Returns (overload 4)

```typescript theme={null}
Promise<StructuredData<T>>
```

## Parameters (overload 5)

<ParamField body="options" type={"SessionScrapeOptions<unknown>"} required />

## Returns (overload 5)

```typescript theme={null}
Promise<ScrapeResult<unknown>>
```

## Example

```typescript theme={null}
const markdown = await session.scrape({ only_main_content: true });
const images = await session.scrape({ only_images: true });
const product = await session.scrape({ response_format: Product, instructions: 'Extract the product' });
const result = await session.scrape({ response_format: Product, raiseOnFailure: false });
if (result.success) console.log(result.data);
```

## Related types

* [ImageData](/typescript-sdk-reference/types/imagedata)
* [ScrapeResult](/typescript-sdk-reference/types/scraperesult)
* [SessionScrapeOptions](/typescript-sdk-reference/types/sessionscrapeoptions)
* [StructuredData](/typescript-sdk-reference/types/structureddata)
* [ZodLikeSchema](/typescript-sdk-reference/types/zodlikeschema)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.