LM Studio Веб-скребок Поставщик Инструментов Поставщик инструментов для LM Studio, который позволяет моделям ИИ просматривать и извлекать контент из веб-страниц с помощью Puppeteer. Это расширение предоставляет инструменты для получения, очистки и возврата структурированного HTML-контента из URL.

71 Downloads

README

LM Studio Web Scraper Tool Provider

A tool provider for LM Studio that enables AI models to browse and extract content from web pages using Puppeteer. This extension provides tools to fetch, clean, and return structured HTML content from URLs.

🚀 Features

  • Web Browsing: Allows the LLM to access live web content via fetch or fetch_all.
  • Content Cleaning: Automatically strips scripts, styles, ads, navigation bars, forms, and other non-essential elements to reduce token usage and focus on main text.
  • Concurrency: Supports fetching multiple URLs simultaneously with fetch_all.
  • Timeout Handling: Includes a 30-second timeout per page load to prevent hanging.

📦 Prerequisites

Before using this tool provider, ensure your environment meets the following requirements:

  • Node.js (v18+ recommended)
  • LM Studio SDK installed (@lmstudio/sdk)
  • Puppeteer (for headless browser automation)
  • Zod (for parameter validation)
  • System Dependencies: Puppeteer requires specific system libraries depending on your OS (e.g., libgbm-dev on Linux, or standard Chromium dependencies).

📖 Usage in LM Studio

To use this tool provider within LM Studio:

  • Configure Tool Provider: Point LM Studio to load this module as a custom tool provider extension.
  • Available Tools: Once loaded, the AI model will have access to two specific tools:

fetch

Fetches and cleans the content of a single web page.

  • Description: Fetches the content of a web page at the given URL, cleans it (removes scripts/styles), and returns the result.
  • Parameters:
    • url (string): A valid URL to fetch.
  • Example Usage:
    { "name": "fetch", "arguments": { "url": "https://example.com" } }
    

fetch_all

Fetches and cleans the content of multiple web pages concurrently.

  • Description: Fetches the content of multiple web pages at the given URLs, cleans them, and returns the results as an array.
  • Parameters:
    • urls (array): An array of valid URLs to fetch.
  • Example Usage:
    { "name": "fetch_all", "arguments": { "urls": ["https://example.com", "https://lmstudio.ai"] } }
    

⚙️ Configuration & Behavior

Content Cleaning Logic

To optimize the output for LLM consumption, the scraper performs aggressive cleaning:

  • Removed Elements: <script>, <style>, <link>, <form>, <input>, <button>, <header>, <footer>, <nav>, <svg>, <iframe>, <audio>, <video>, etc.
  • Node Processing: Removes empty nodes, comments, and whitespace-only text nodes.
  • Attribute Stripping: Removes all attributes except src and href.

Performance & Timeouts

  • Wait Strategy: Waits for domcontentloaded and networkidle0.
  • Timeout: 30 seconds per page (30 * 1000).
  • Resource Blocking: Images, media, stylesheets, and fonts are blocked during loading to speed up the process.