Skip to main content
Glama

web-speed-agent

PyPI version Python License: GPL v3

認証済みWeb抽出のためのローカルブラウザ自動化 + Web Speed API 統合。

AIエージェントを任意のWebサイト(ログインが必要なサイトを含む)に向けるだけで、クリーンで構造化されたデータを取得できます。認証情報はマシン内に留まります。抽出されたHTMLのみがサーバーに送信されます。

pip install web-speed-agent
playwright install chromium

Claude、Gemini、その他のAIクライアントでこれを使用したいですか?

MCPサーバーインストールガイド を確認してください。AIエージェントが自然言語を通じてログインし、データを抽出できるようにする最も簡単な方法です。


仕組み

Your machine                           Web Speed server
─────────────────────────────────      ──────────────────────────
Playwright browser (local)
  ↓ navigates, logs in, clicks
  ↓ gets page HTML
  ↓ (no passwords sent)
agent.extract(html)         ────────→  Advanced extraction engine
                            ←────────  Structured JSON

認証情報がマシンから出ることはありません。サーバーはHTMLのみを参照します。


Related MCP server: Agent Identity MCP Server

クイックスタート

import asyncio
from web_speed_agent import Agent

async def main():
    agent = Agent(api_key="wsp_...")       # or set WEBSPEED_API_KEY env var

    # Public pages — no browser needed
    result = await agent.map("https://techcrunch.com/some-article/")
    print(result["article"]["sections"])

    # Authenticated pages — browser runs locally
    agent.store_credential("mysite", "me@example.com", "mypassword")

    async with agent.browser(session_name="mysite") as browser:
        page = await browser.new_page()
        await page.goto("https://mysite.com/login")

        username, password = agent.get_credential("mysite")
        await page.fill('[name="email"]', username)
        await page.fill('[name="password"]', password)
        await page.click('button[type="submit"]')
        await page.wait_for_load_state("networkidle")

        # Now on a logged-in page — extract it
        html = await page.content()
        result = await agent.extract(html, page_type="listing")
        print(result["listing"]["items"])

asyncio.run(main())

getwebspeed.io でAPIキーを取得してください。


インストール

要件: Python 3.10+、Web Speed APIキー

pip install web-speed-agent
playwright install chromium
export WEBSPEED_API_KEY="wsp_..."

基本概念

Agent

メインクラス。認証情報、ブラウザセッション、API呼び出しを管理します。

from web_speed_agent import Agent

# API key from argument
agent = Agent(api_key="wsp_...")

# API key from environment variable (recommended)
# export WEBSPEED_API_KEY="wsp_..."
agent = Agent()

# Use as async context manager (auto-closes HTTP client)
async with Agent() as agent:
    ...

公開ページの抽出

ログイン不要のページにはブラウザは不要です:

# Fetch + extract in one call
result = await agent.map("https://example.com/article")

# With JavaScript rendering (for heavy SPAs)
result = await agent.map("https://example.com/spa", js=True)

認証済みページの抽出

ローカルブラウザセッションを使用します。ブラウザはマシン上で実行されます:

async with agent.browser(session_name="mysite") as browser:
    page = await browser.new_page()
    await page.goto("https://mysite.com/dashboard")
    html = await page.content()

result = await agent.extract(html)

session_name はCookieを ~/.webspeed/sessions/<name>/ に永続化するため、以降の実行ではログイン手順をスキップできます。


認証情報の管理

認証情報はシステムのキーチェーン(macOS Keychain、Windows Credential Manager、Linux secret-tool)に保存されます。これらが Web Speedサーバーに送信されることは決してありません

# Store once
agent.store_credential("mysite", "me@example.com", "mypassword")

# Retrieve anywhere
username, password = agent.get_credential("mysite")

# Remove
agent.delete_credential("mysite")

抽出出力

サーバーはページタイプを認識した構造化データを返します:

# Article
result = await agent.extract(html, page_type="article")
# result["page_type"]    → "article"
# result["title"]        → "Article Title"
# result["author"]       → "Jane Smith"
# result["published_date"] → "2026-05-06"
# result["article"]["sections"] → [{"heading": "...", "paragraphs": [...]}]
# result["article"]["links"]    → [{"text": "...", "url": "..."}]

# Product
result = await agent.extract(html, page_type="product")
# result["product"]["name"]         → "Wireless Headphones"
# result["product"]["price"]        → "$99.99"
# result["product"]["availability"] → "In Stock"
# result["product"]["rating"]       → "4.5"
# result["product"]["specs"]        → {"Battery": "30h", ...}

# Listing (search results, category pages)
result = await agent.extract(html, page_type="listing")
# result["listing"]["items"] → [{"title": "...", "url": "...", "price": "..."}]

# Auto-detect (default)
result = await agent.extract(html)
# result["page_type"] → "article" | "product" | "listing" | "other"

すべての結果には engine: "advanced" が含まれており、生のHTMLよりも60〜85%トークン効率が高くなっています。


価格モニター

import asyncio
from web_speed_agent import Agent

async def check_price(url: str, site_name: str) -> str:
    async with Agent() as agent:
        agent.store_credential(site_name, "me@example.com", "password", overwrite=True)

        async with agent.browser(session_name=site_name) as browser:
            page = await browser.new_page()

            # Login
            await page.goto(f"https://{site_name}.com/login")
            user, pwd = agent.get_credential(site_name)
            await page.fill('[name="email"]', user)
            await page.fill('[name="password"]', pwd)
            await page.click('button[type="submit"]')
            await page.wait_for_load_state("networkidle")

            # Check product
            await page.goto(url)
            await page.wait_for_load_state("networkidle")
            html = await page.content()

        result = await agent.extract(html, page_type="product")
        return result.get("product", {}).get("price", "unknown")

price = asyncio.run(check_price("https://example.com/product/123", "example"))
print(f"Current price: {price}")

プライベートダッシュボードの読み取り

import asyncio
from web_speed_agent import Agent

async def get_dashboard_data():
    async with Agent() as agent:
        async with agent.browser(session_name="analytics") as browser:
            page = await browser.new_page()

            # Login (first run only — session persists after)
            creds = agent.get_credential("analytics")
            if not creds:
                agent.store_credential("analytics", "me@company.com", "password")
                creds = agent.get_credential("analytics")

            await page.goto("https://analytics.company.com/login")
            await page.fill('[name="email"]', creds[0])
            await page.fill('[name="password"]', creds[1])
            await page.click('button[type="submit"]')
            await page.wait_for_load_state("networkidle")

            # Navigate to dashboard
            await page.goto("https://analytics.company.com/dashboard")
            await page.wait_for_selector(".metrics-table", timeout=10000)
            html = await page.content()

        result = await agent.extract(html)
        return result

asyncio.run(get_dashboard_data())

ログイン中の複数ページスクレイピング

import asyncio
from web_speed_agent import Agent

async def scrape_inbox():
    async with Agent() as agent:
        async with agent.browser(session_name="webmail") as browser:
            page = await browser.new_page()

            # Login
            await page.goto("https://mail.example.com/login")
            user, pwd = agent.get_credential("webmail")
            await page.fill('[name="username"]', user)
            await page.fill('[name="password"]', pwd)
            await page.click('[type="submit"]')
            await page.wait_for_load_state("networkidle")

            # Scrape multiple pages
            emails = []
            for page_num in range(1, 4):
                await page.goto(f"https://mail.example.com/inbox?page={page_num}")
                await page.wait_for_load_state("networkidle")
                html = await page.content()
                result = await agent.extract(html, page_type="listing")
                emails.extend(result.get("listing", {}).get("items", []))

        return emails

asyncio.run(scrape_inbox())

AIエージェント統合 (MCP)

付属のMCPサーバーを使用すると、Claude Desktop、Gemini CLI、およびMCP互換エージェントがSDKを直接使用できます。エージェントは、自然言語を通じてログイン、ナビゲート、クリック、抽出を行うことができます。

MCPサーバーの起動:

WEBSPEED_API_KEY="wsp_..." python3 agent_mcp_server.py

Claude Desktopに追加 (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "web-speed-agent": {
      "command": "python3",
      "args": ["/path/to/agent_mcp_server.py"],
      "env": {
        "WEBSPEED_API_KEY": "wsp_..."
      }
    }
  }
}

Gemini CLIに追加 (~/.gemini/settings.json):

{
  "mcpServers": {
    "web-speed-agent": {
      "command": "python3.11",
      "args": ["/path/to/agent_mcp_server.py"],
      "env": {
        "WEBSPEED_API_KEY": "wsp_...",
        "PYTHONPATH": "/path/to/web-speed-agent"
      }
    }
  }
}

次に、エージェントに指示します:

"unitedの認証情報を保存して — ユーザー名は me@example.com、パスワードは mypassword"

"united.comにログインして、来週の金曜日のSFOからJFKへの最安値のフライトを見つけて"

利用可能なMCPツール:

ツール

説明

store_credential

システムキーチェーンにログイン情報を保存

login

ブラウザを開いてサインイン

navigate

アクティブなセッションでURLに移動

extract_page

現在のページから構造化データを取得

click

ボタンやリンクをクリック

fill_field

フォームフィールドに入力

submit_form

フォームを送信

close_browser

ブラウザセッションを終了

account_info

APIクレジット残高を確認


APIリファレンス

Agent

Agent(
    api_key: str | None = None,
    server_url: str | None = None,
    config_dir: str = "~/.webspeed",
    headless: bool = True,
)

パラメータ

説明

api_key

Web Speed APIキー。WEBSPEED_API_KEY 環境変数にフォールバックします。

server_url

APIサーバーURLを上書きします。デフォルト: https://api.getwebspeed.io

config_dir

設定、セッション、ログ用のディレクトリ。デフォルト: ~/.webspeed

headless

ブラウザをヘッドレスで実行します。デフォルト: True


agent.browser()

agent.browser(
    session_name: str | None = None,
    headless: bool | None = None,
    proxy: str | None = None,
) -> ManagedBrowser

非同期コンテキストマネージャーを返します。ブロック内で .new_page() を呼び出してPlaywrightの Page を取得します。

パラメータ

説明

session_name

Cookieを ~/.webspeed/sessions/<name>/ に永続化します。None = 永続化なし。

headless

このセッションのインスタンスの headless を上書きします。

proxy

プロキシURL(例: "socks5://localhost:1080")。

セッション名は英数字とハイフン/アンダースコアで構成し、最大64文字である必要があります。


agent.extract()

await agent.extract(
    html: str,
    page_type: str = "auto",
) -> dict

HTMLをWeb Speed APIに送信します。1クレジットを消費します。

パラメータ

説明

html

生のHTML文字列(例: page.content() から)。

page_type

"article""product""listing"、または "auto"


agent.map()

await agent.map(
    url: str,
    js: bool = False,
) -> dict

サーバー経由で公開URLを取得および抽出します。ローカルブラウザは不要です。1クレジットを消費します。

パラメータ

説明

url

ページのURL。http:// または https:// である必要があります。

js

抽出前にJavaScriptをレンダリングします。


agent.account()

await agent.account() -> dict

creditstierstatuslifetime(合計/成功/失敗)を返します。


agent.store_credential()

agent.store_credential(
    site: str,
    username: str,
    password: str,
    overwrite: bool = False,
) -> None

システムキーチェーンに保存します。認証情報が存在し、overwrite=False の場合に CredentialError を発生させます。


agent.get_credential()

agent.get_credential(site: str) -> tuple[str, str] | None

(username, password) を返します。見つからない場合は None を返します。


agent.delete_credential()

agent.delete_credential(site: str) -> None

キーチェーンから認証情報を削除します。


例外

from web_speed_agent import (
    WebSpeedError,          # Base exception
    AuthenticationError,    # Invalid/missing API key
    InsufficientCreditsError, # No credits remaining
    APIError,               # API returned 4xx/5xx
    RateLimitError,         # 429 Too Many Requests
    CredentialError,        # Keychain error
    BrowserError,           # Playwright error
    NetworkError,           # Timeout or DNS failure
    PlaywrightNotInstalledError, # Run: playwright install chromium
)
from web_speed_agent import Agent, InsufficientCreditsError, NetworkError

try:
    result = await agent.extract(html)
except InsufficientCreditsError:
    print("Out of credits — top up at getwebspeed.io")
except NetworkError as e:
    print(f"Connection failed: {e}")

設定

環境変数

変数

説明

WEBSPEED_API_KEY

APIキー(設定ファイルよりも推奨)

WEBSPEED_SERVER_URL

サーバーURLを上書き(https:// である必要があります)

設定ファイル

~/.webspeed/config.yaml — 初回実行時に自動的に作成されます。権限は 0o600(所有者のみ)に設定されます。

api:
  server_url: https://api.getwebspeed.io
  timeout: 30

browser:
  headless: true

セッションファイル

永続化されたブラウザセッションは ~/.webspeed/sessions/<name>/storage.json に保存されます。

  • 権限: 0o600(所有者のみ)

  • 内容: Cookie、localStorage、sessionStorage

  • 削除しても安全: 次回実行時にエージェントが再認証します


セキュリティ

マシンから出るもの

agent.extract(html) を呼び出すと、ページHTMLが処理のためにWeb Speed APIに送信されます。それ以外はすべてローカルに留まります。

データ

送信先

ログイン認証情報

マシンから出ることはありません(システムキーチェーンのみ)

ブラウザCookie / セッション

マシンから出ることはありません(ローカルPlaywright)

ページHTML

抽出のためにHTTPS経由でWeb Speed APIに送信

抽出されたJSON

あなたに返されます

HTMLスクラビング(デフォルトで有効)

HTMLが送信される前に、SDKはローカルで自動的にスクラビングを行います:

  • インラインの <script> および <style> ブロックを削除

  • 認証関連の名前(csrftokennoncesession など)を持つ非表示のフォームフィールドの値を空白化

  • 機密性の高い <meta> コンテンツ属性をクリア

  • HTMLコメントを削除

表示コンテンツ(テキスト、リンク、テーブル、見出し、製品データ)は変更されません。

# Default: scrubbing is on
result = await agent.extract(html)

# Turn off only if the page has no sensitive data
result = await agent.extract(html, scrub=False)

# Or scrub manually and inspect before sending
from web_speed_agent import scrub
clean_html = scrub(raw_html)
print(clean_html)  # inspect what will be sent
result = await agent.extract(clean_html, scrub=False)

サーバー側のデータ処理

  • HTMLはメモリ内でのみ処理 — ディスクへの書き込み、ログ記録、キャッシュは一切行われません

  • 認証が必要なページはキャッシュされません — ログインが必要なページは共有レジストリから明示的に除外されます

  • 使用ログには以下のみを保存: APIキーのハッシュ、URLのハッシュ(または "sdk-extract")、タイムスタンプ、検出されたページタイプ — コンテンツは保存されません

  • エラー応答に生のHTMLは含まれません — 例外はエラーが返される前にサニタイズされます

その他の保護

  • 認証情報はシステムキーチェーンに保存され、ファイルに保存されたり、サーバーに送信されたりすることはありません

  • セッションファイル0o600 権限(所有者のみ読み取り/書き込み)で書き込まれます

  • 設定ディレクトリ0o700 権限で作成されます

  • TLSは常に検証 — すべてのHTTP呼び出しで verify=True が設定され、無効にすることはできません

  • HTTPSを強制server_urlhttps:// で始まる必要があり、プレーンなHTTPは拒否されます

  • パストラバーサル防止 — セッション名は [a-zA-Z0-9_-] の許可リストに対して検証されます

  • 認証情報のログ記録なし — パスワードがログやエラーメッセージに表示されることはありません


ライセンス

GNU General Public License v3.0 — LICENSE を参照してください。

Web Speed APIの使用には Web Speed利用規約 が適用されます。

A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Provides an MCP-native agent browser that enables autonomous agents to perceive and interact with web pages through stealth browsing, identity borrowing, and WAAP detection.
    9
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables MCP-capable runtimes to read agent message rooms, sign and post public messages, and create or verify Ed25519 contribution proofs for Technocore.
    MIT

View all related MCP servers

Related MCP Connectors

  • Agent-first web hosting: deploy sites, apps, databases and domains over MCP.

  • Hosted AgentLux MCP server for marketplace, identity, creator, services, and social flows.

  • MCP Server for agents to onboard, pay, and provision services autonomously with InFlow

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Dominic-Pi-Sunyer/web-speed-agent'

If you have feedback or need assistance with the MCP directory API, please join our Discord server