llm-scraper is a free, open source browsers & extensions project written in TypeScript and released under MIT. It has 6,933 GitHub stars, 454 forks and 9 open issues, and was last pushed 8 days ago. On this registry it ranks #50 of 101 tracked projects in Browsers & Extensions, with 5 head-to-head comparisons available.

What is llm-scraper?

LLM Scraper is an MIT-licensed TypeScript library that turns any webpage into structured data by combining Playwright with a large language model, built for developers who want typed, schema-shaped extraction instead of hand-written selectors.

What it is

LLM Scraper is a TypeScript library published to npm that extracts structured data from any webpage using LLMs. It lives in the Node.js and TypeScript ecosystem, depends on the Playwright browser automation framework, and is designed around the Vercel AI SDK provider abstraction. Schemas are declared with Zod or JSON Schema, and the library carries that typing through to the returned object, so the shape of extracted data is known at compile time. Version 2.0 added support for Vercel AI SDK 6 along with updated examples.

The concrete thing it replaces is the hand-written scraper: the CSS selectors, XPath expressions, and brittle parsing code that break whenever a site redesigns its markup. Instead of encoding where a value lives in the DOM, the developer describes what the value is through a schema, and the model reads the page content to fill it. Six formatting modes decide what the model actually sees: html for pre-processed HTML, raw_html for unprocessed markup, markdown, text using Readability.js, image for a screenshot in multi-modal setups, and custom for content supplied by a user function.

Key capabilities

  • Defines extraction targets with Zod or JSON Schema, with full TypeScript type-safety on results.
  • Runs on the Playwright framework, so pages are loaded in a real browser before extraction.
  • Supports GPT, Sonnet, Gemini, Llama, and Qwen model series through AI SDK providers such as @ai-sdk/openai, @ai-sdk/anthropic, and @ai-sdk/google.
  • Works with Groq through createOpenAI pointed at https://api.groq.com/openai/v1, and with local models through ollama-ai-provider-v2.
  • Offers six content formats — html, raw_html, markdown, text, image, and custom — to control what is sent to the model.
  • Streams partial objects: scraper.stream(page, Output.object({ schema })) yields results as they arrive instead of waiting for the full object.
  • Includes code-generation, where the generate function produces a reusable Playwright script for the same scraping task.

Who uses it and how

  • Teams that already run Playwright-based browser automation and want to replace selector maintenance with schema definitions.
  • Developers building data pipelines against sites whose markup changes often, where re-tuning selectors costs more than a model call.
  • Applications that need typed output downstream, using Zod schemas so extracted records flow into typed TypeScript code.
  • Interfaces that benefit from progressive rendering, consuming stream to display partial results while the model is still generating.
  • Multi-modal workflows that pass image format screenshots to a vision-capable model when text extraction is insufficient.

Getting started

Install from npm with npm i zod playwright llm-scraper, add the provider package for the chosen model, then construct new LLMScraper(llm) and call scraper.run(page, Output.object({ schema }), { format: 'html' }) against a Playwright page.

How it compares

The facts place LLM Scraper alongside Playwright and Puppeteer in its topic list, but it is not an alternative to them: it is built on Playwright and uses the browser as its page-loading layer, so the two are complementary rather than competing. It also appears alongside LangChain in the same topic set, though the README positions the library as a focused scraping tool with its own schema and formatting API rather than a general orchestration framework. No list of paid products it replaces is provided, so no commercial comparison can be made.

When to use it — and when not to

A self-hoster must supply their own model access, whether that means an API key and per-token billing for OpenAI, Anthropic, Google, or Groq, or a locally hosted Ollama instance, plus a Playwright browser installation and the Node.js runtime. It is not a good fit for high-volume, deterministic extraction where a fixed selector would be faster, cheaper, and reproducible, because every page costs a model call and the output is inherently probabilistic. The MIT licence is clear and the repository is active, but the README covers usage rather than operational concerns: it says nothing about rate limiting, retries, caching, or production scaling, so those are left to the integrator.

project readme (upstream, from github) — read inline

LLM Scraper

Screenshot 2024-04-20 at 23 11 16

LLM Scraper is a TypeScript library that allows you to extract structured data from any webpage using LLMs.

[!IMPORTANT] LLM Scraper was updated to version 2.0.

The new version comes with Vercel AI SDK 6 support and updated examples.

Features

  • Supports GPT, Sonnet, Gemini, Llama, Qwen model series
  • Schemas defined with Zod or JSON Schema
  • Full type-safety with TypeScript
  • Based on Playwright framework
  • Streaming objects
  • Code-generation
  • Supports 6 formatting modes:
    • html for loading pre-processed HTML
    • raw_html for loading raw HTML (no processing)
    • markdown for loading markdown
    • text for loading extracted text (using Readability.js)
    • image for loading a screenshot (multi-modal only)
    • custom for loading custom content (using a custom function)

Make sure to give it a star!

Screenshot 2024-04-20 at 22 13 32

Getting started

  1. Install the required dependencies from npm:

    npm i zod playwright llm-scraper
    
  2. Initialize your LLM:

    OpenAI

    npm i @ai-sdk/openai
    
    import { openai } from '@ai-sdk/openai'
    
    const llm = openai('gpt-4o')
    

    Anthropic

    npm i @ai-sdk/anthropic
    
    import { anthropic } from '@ai-sdk/anthropic'
    
    const llm = anthropic('claude-3-5-sonnet-20240620')
    

    Google

    npm i @ai-sdk/google
    
    import { google } from '@ai-sdk/google'
    
    const llm = google('gemini-1.5-flash')
    

    Groq

    npm i @ai-sdk/openai
    
    import { createOpenAI } from '@ai-sdk/openai'
    const groq = createOpenAI({
      baseURL: 'https://api.groq.com/openai/v1',
      apiKey: process.env.GROQ_API_KEY,
    })
    
    const llm = groq('llama3-8b-8192')
    

    Ollama

    npm i ollama-ai-provider-v2
    
    import { ollama } from 'ollama-ai-provider-v2'
    
    const llm = ollama('llama3')
    
  3. Create a new scraper instance provided with the llm:

    import LLMScraper from 'llm-scraper'
    
    const scraper = new LLMScraper(llm)
    

Example

In this example, we're extracting top stories from HackerNews:

import { chromium } from 'playwright'
import { z } from 'zod'
import { Output } from 'ai'
import { openai } from '@ai-sdk/openai'
import LLMScraper from 'llm-scraper'

// Launch a browser instance
const browser = await chromium.launch()

// Initialize LLM provider
const llm = openai('gpt-4o')

// Create a new LLMScraper
const scraper = new LLMScraper(llm)

// Open new page
const page = await browser.newPage()
await page.goto('https://news.ycombinator.com')

// Define schema to extract contents into
const schema = z.object({
  top: z
    .array(
      z.object({
        title: z.string(),
        points: z.number(),
        by: z.string(),
        commentsURL: z.string(),
      })
    )
    .length(5)
    .describe('Top 5 stories on Hacker News'),
})

// Run the scraper
const { data } = await scraper.run(page, Output.object({ schema }), {
  format: 'html',
})

// Show the result from LLM
console.log(data.top)

await page.close()
await browser.close()

Output

[
  {
    title: "Palette lighting tricks on the Nintendo 64",
    points: 105,
    by: "ibobev",
    commentsURL: "https://news.ycombinator.com/item?id=44014587",
  },
  {
    title: "Push Ifs Up and Fors Down",
    points: 187,
    by: "goranmoomin",
    commentsURL: "https://news.ycombinator.com/item?id=44013157",
  },
  {
    title: "JavaScript's New Superpower: Explicit Resource Management",
    points: 225,
    by: "olalonde",
    commentsURL: "https://news.ycombinator.com/item?id=44012227",
  },
  {
    title: "\"We would be less confidential than Google\" Proton threatens to quit Switzerland",
    points: 65,
    by: "taubek",
    commentsURL: "https://news.ycombinator.com/item?id=44014808",
  },
  {
    title: "OBNC – Oberon-07 Compiler",
    points: 37,
    by: "AlexeyBrin",
    commentsURL: "https://news.ycombinator.com/item?id=44013671",
  }
]

More examples can be found in the examples folder.

Streaming

Replace your run function with stream to get a partial object stream.

// Run the scraper in streaming mode
const { stream } = await scraper.stream(page, Output.object({ schema }))

// Stream the result from LLM
for await (const data of stream) {
  console.log(data.top)
}

Code-generation

Using the generate function you can generate re-usable playwright script that scrapes the contents according to a schema.

// Generate code and run it on the page
const { code } = await scraper.generate(page, Output.object({ schema }))
const result = await page.evaluate(code)
const data = schema.parse(result)

// Show the parsed result
console.log(data.top)

Contributing

As an open-source project, we welcome contributions from the community. If you are experiencing any bugs or want to add some improvements, please feel free to open an issue or pull request.

Frequently asked questions

Is llm-scraper free to use?

llm-scraper is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does llm-scraper do?

Turn any webpage into structured data using LLMs

What is llm-scraper written in?

llm-scraper is primarily written in TypeScript. Its source is publicly available at https://github.com/mishushakov/llm-scraper, and it has 6,933 GitHub stars.