Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

llm-scraper

> DevOps
Open source

Turn any webpage into structured data using LLMs

6.9K stars0 likes0 views
WebsiteGitHub

About

Turn any webpage into structured data using LLMs

LLM Scraper

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!

Getting started

  1. Install the required dependencies from npm:

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

    OpenAI

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

    Anthropic

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

    Google

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

    Groq

    bash
    npm i @ai-sdk/openai
    javascript
    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

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

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

Example

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

…

Output

…

More examples can be found in the examples folder.

Streaming

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

typescript
// 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.

typescript
// 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.

Issues· 9 open

View all issuesOpen on GitHub
  • #8

    Fix Readable.js on certain pages (like HN)

    Updated Jul 9, 2025
  • #23

    Standardised testing for package

    Updated May 6, 2024
  • #20

    Bug: `tool_calls` is sometimes undefined

    Updated May 1, 2024

> Tags

TypeScriptaiartificial-intelligencebrowserbrowser-automation

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 23, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理