VS Code の Copilot でのウェブスクレイピング
VS Code に Spicrawl MCP サーバーを追加します。エージェントモードの Copilot はウェブページをクリーンな Markdown として読めるようになります。
セットアップする
3 つの手順で、Copilot にツール、Spicrawl のコードを書くための知識、両方を使うためのルールを与えます。最初の 2 つは spicrawl init --client vscode が行います。
プロジェクトに
.vscode/mcp.jsonを作成します。VS Code ではmcpServersではなくserversキーを使います。パスワード入力により、VS Code がキーを一度だけ尋ねて保存するため、このファイルはコミットしても安全です:.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}" } } } }コマンドパレットから MCP: List Servers を実行し、
spicrawlを開始します。求められたらキーを入力してください。スキルをインストールして、コミットします:
bashspicrawl 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これを
.github/copilot-instructions.mdとして保存するか、すでにあるファイルに追加してください:.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.Chat ビューを開き、エージェント モードに切り替えて、ツールピッカーを開きます。
spicrawlにはspicrawl_*ツールが 25 個表示されます。
Copilot CLI と Copilot クラウドエージェントは、それぞれ独自の MCP 設定を読み込みます。ドキュメントページ は両方を扱っています。
最初に試すタスク
Copilot Chat をエージェントモードで開き、次のように依頼してください:
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.エージェントは format: "markdown" を指定して spicrawl_scrape を呼び出します。最初の結果が空の場合のみ render: true を追加します。
できること
このサーバーは、エージェントに spicrawl_* ツールを 25 個提供します。各呼び出しはお客様の API キーのもとで実行され、API の直接呼び出しと同じ制限とクレジットが適用されます。
- ページを一つ読み取る:
spicrawl_scrapeは Markdown(デフォルト)、テキスト、HTML、JSON、PDF を返します。 - 多数のページを読み取る:
spicrawl_batch_submitは最大 10,000 件の URL をキューに入れます。続けてspicrawl_batch_statusとspicrawl_batch_resultsを使います。 - ログインが必要なページ:
spicrawl_session_createは、呼び出しをまたいで Cookie とストレージを保持します。 - 失敗をデバッグする:
spicrawl_requests_listとspicrawl_request_get。 - 使用量を確認:
spicrawl_usage_summaryとその他の使用量ツール。これらにはreadスコープを持つキーが必要です。 - 調べる:
spicrawl_docs_searchとspicrawl_docs_readで Spicrawl のドキュメントを検索して読めます。
ツール spicrawl_browser_connect_url は一覧にありますが、近日公開です。spicrawl_scrape では、レンダリングの引数は API の js_render ではなく render です。
知っておくべきこと
- クロールはありません。 Spicrawl はリンクをたどったり、ページを探したりしません。エージェントに URL を渡してください。
- リクエストごとのクレジット。 通常のフェッチは 1 クレジット、JavaScript レンダリングは 3、フルブラウザレンダリングは 8 です。
- 失敗は無料です。 失敗したリクエストは 0 クレジットです。
- キャッシュで節約できるのは時間であり、クレジットではありません。 キャッシュヒットの料金は、それを保存したフェッチと同じです。
- 呼び出しごとに上限を設けてください。
max_costを設定すると、より高くなる可能性のあるリクエストは実行前に拒否されます。 - 近日公開: マネージドプロキシ、ステルスモード、リモートブラウザ、自然な言葉で書いたプロンプトからの AI 抽出。現時点では、ご自身のプロキシを使えます。
よくある質問
VS Code が「mcpServers」ではなく「servers」を使うのはなぜですか?
これは VS Code 独自の形式です。このページの例のとおり、.vscode/mcp.json では servers キーを使ってください。
キーはどこに保存されますか?
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.
Copilot CLI とクラウドエージェントで動作しますか?
はい。ただし、それぞれが独自の MCP 設定を読み取ります。Copilot CLI は copilot mcp add を使います。クラウドエージェントは、リポジトリの管理者が Settings → Copilot → MCP servers で設定します。ドキュメントのページで両方を説明しています。
spicrawl init --client vscode は何を書き込みますか?
.vscode/mcp.json と、.github/skills/spicrawl/SKILL.md のスキルを書き込みます。指示ファイル、Copilot CLI、クラウドエージェントの設定は書き込みません。
1 ページの料金はいくらですか?
通常のフェッチは 1 クレジット、JavaScript レンダリングは 3、フルブラウザレンダリングは 8 です。失敗したリクエストは 0 クレジットです。キャッシュヒットは、それを保存したフェッチと同じ料金です。エージェントに各リクエストで max_cost を設定するよう指示すれば、想定以上の出費を防げます。