Spicrawl funktioniert jetzt mit dem OpenAI Agents SDK, LangChain, Codex, Claude Code und mehr.Integrationen ansehen
Zum Inhalt springen

Web Scraping in VS Code mit Copilot

Füge den Spicrawl-MCP-Server zu VS Code hinzu. Copilot im Agent-Modus kann dann Webseiten als sauberes Markdown lesen.

Einrichten

Drei Schritte geben Copilot die Tools, das Know-how zum Schreiben von Spicrawl-Code und Regeln für beides. spicrawl init --client vscode erledigt die ersten beiden für dich.

  1. Lege .vscode/mcp.json im Projekt an. VS Code nutzt den Schlüssel servers, nicht mcpServers. Das Passwortfeld lässt VS Code einmal nach deinem Schlüssel fragen und ihn speichern, sodass die Datei bedenkenlos committet werden kann:

    .vscode/mcp.json
    {
      "inputs": [
        {
          "type": "promptString",
          "id": "spicrawl-api-key",
          "description": "Spicrawl API key",
          "password": true
        }
      ],
      "servers": {
        "spicrawl": {
          "type": "http",
          "url": "https://mcp.spicrawl.com/mcp",
          "headers": { "Authorization": "Bearer ${input:spicrawl-api-key}" }
        }
      }
    }
  2. Führe MCP: List Servers über die Command Palette aus und starte spicrawl. Gib deinen Schlüssel ein, wenn du gefragt wirst.

  3. Installiere den Skill und committe ihn:

    bash
    spicrawl skill install --client vscode
    
    # Without the CLI:
    mkdir -p .github/skills/spicrawl
    curl -fsSL https://app.spicrawl.com/skill.md -o .github/skills/spicrawl/SKILL.md
  4. Speichere dies als .github/copilot-instructions.md oder füge es in die Datei ein, die du schon hast:

    .github/copilot-instructions.md
    # Web data (Spicrawl)
    
    Use Spicrawl to read web pages: the spicrawl_* MCP tools in chat, or
    POST https://api.spicrawl.com/v1/scrape with `Authorization: Bearer $SPICRAWL_API_KEY` in code.
    Docs: https://docs.spicrawl.com/llms.txt (append .md to any page URL for Markdown).
    
    - Ask for markdown: `response_format: "markdown"` (API default is html); on spicrawl_scrape, `format: "markdown"`.
    - Check the site's status, not only the HTTP status: `X-Target-Status` header, or `status`
      in the JSON envelope (spicrawl_scrape with `format: "json"`). 200 is the page; 404/410
      mean it does not exist; 403/429/503 mean the site refused, so escalate.
    - On an error, switch on `code`. Retry only when `retryable` is true, after
      `retry_after_seconds`. Read `diagnostics.hint` and change what it names first.
      Never retry ERR::REQUEST::*, ERR::AUTH::* or ERR::LIMIT::QUOTA_EXCEEDED.
    - Escalate one step at a time and stop at the first that works:
      plain fetch (1 credit) -> `js_render: true` (3) -> add the user's own `proxy`
      if they have one. Empty or skeleton content means render; ERR::UPSTREAM::CHALLENGE
      or a 403 target status means retry once, then the user's own proxy.
    - Set `max_cost` on every request to the price of the step you intend.
    - Keep the cache on (default). Set `cache: false` only for prices, stock or other live data.
    - Trim tokens with `main_content_only` (on by default for markdown), `include_tags`, `exclude_tags`.
    - For more than 20 URLs, use a batch job (spicrawl_batch_submit / POST /v1/batch).
      Batch items return html, markdown or text (spicrawl_batch_submit defaults to markdown,
      POST /v1/batch to html). Extraction, screenshots, actions and sessions are refused
      with a 400 before anything is charged: scrape those URLs one by one.
    - Never print or commit SPICRAWL_API_KEY. Log `X-Request-Id` for failures.
  5. Öffne die Chat-Ansicht, wechsle in den Modus Agent und öffne die Tool-Auswahl. spicrawl listet 25 spicrawl_*-Tools auf.

Die Copilot CLI und der Copilot-Cloud-Agent lesen jeweils ihre eigene MCP-Konfiguration. Die Docs-Seite deckt beide ab.

Eine erste Aufgabe zum Ausprobieren

Öffne Copilot Chat im Agent-Modus und frage:

Prompt
Use Spicrawl to read https://example.com/pricing as markdown. List each plan with its monthly price.
If the page comes back empty, retry with rendering.

Der Agent sollte spicrawl_scrape mit format: "markdown" aufrufen. Er sollte render: true nur hinzufügen, wenn das erste Ergebnis leer ist.

Was es kann

Der Server gibt dem Agenten 25 spicrawl_*-Tools. Jeder Aufruf läuft unter deinem API-Schlüssel, mit denselben Limits und Credits wie ein direkter API-Aufruf.

  • Eine Seite lesen: spicrawl_scrape liefert Markdown (Standard), Text, HTML, JSON oder PDF.
  • Viele Seiten lesen: spicrawl_batch_submit stellt bis zu 10.000 URLs in die Warteschlange. Danach folgen spicrawl_batch_status und spicrawl_batch_results.
  • Seiten hinter einem Login: spicrawl_session_create behält Cookies und Storage über Aufrufe hinweg.
  • Einen Fehler debuggen: spicrawl_requests_list und spicrawl_request_get.
  • Nutzung prüfen: spicrawl_usage_summary und die anderen Nutzungs-Tools. Dafür brauchst du einen Schlüssel mit dem Scope read.
  • Dinge nachschlagen: spicrawl_docs_search und spicrawl_docs_read durchsuchen und lesen die Spicrawl-Docs.

Ein Tool, spicrawl_browser_connect_url, ist aufgeführt, kommt aber bald. Bei spicrawl_scrape heißt das Rendering-Argument render, nicht js_render wie bei der API.

Gut zu wissen

  • Kein Crawling. Spicrawl folgt keinen Links und findet keine Seiten. Gib dem Agenten die URLs.
  • Credits pro Anfrage. Ein einfacher Abruf kostet 1 Credit. JavaScript-Rendering kostet 3. Rendering im vollen Browser kostet 8.
  • Fehler sind kostenlos. Eine fehlgeschlagene Anfrage kostet 0 Credits.
  • Der Cache spart Zeit, keine Credits. Ein Cache-Treffer kostet genauso viel wie der Abruf, der ihn gespeichert hat.
  • Begrenze jeden Aufruf. Setze max_cost, und eine Anfrage, die mehr kosten könnte, wird abgelehnt, bevor sie läuft.
  • Kommt bald: verwaltete Proxys, Stealth-Modus, ein Remote-Browser und KI-Extraktion aus einem Prompt in einfacher Sprache. Heute kannst du deinen eigenen Proxy mitbringen.

Häufig gestellte Fragen

Warum nutzt VS Code "servers" und nicht "mcpServers"?

Das ist das eigene Format von VS Code. Nutze den Schlüssel servers in .vscode/mcp.json, wie im Beispiel auf dieser Seite.

Wo wird mein Schlüssel gespeichert?

The inputs entry with password: true makes VS Code ask for the key once and store it. The file only holds ${input:spicrawl-api-key}, so you can commit it.

Funktioniert es mit der Copilot CLI und dem Cloud-Agenten?

Ja, aber jeder liest seine eigene MCP-Konfiguration. Die Copilot CLI nutzt copilot mcp add. Der Cloud-Agent wird von einem Repository-Admin unter Settings → Copilot → MCP servers eingerichtet. Die Docs-Seite deckt beides ab.

Was schreibt spicrawl init --client vscode?

Es schreibt .vscode/mcp.json und den Skill unter .github/skills/spicrawl/SKILL.md. Es schreibt nicht die Instruktionsdatei und nicht die Konfiguration der Copilot CLI oder des Cloud-Agenten.

Was kostet jede Seite?

Ein einfacher Abruf kostet 1 Credit, JavaScript-Rendering 3 und Rendering im vollen Browser 8. Fehlgeschlagene Anfragen kosten 0. Ein Cache-Treffer kostet so viel wie der Abruf, der ihn gespeichert hat. Lass den Agenten bei jeder Anfrage max_cost setzen, damit er nie mehr ausgibt als erwartet.