> ## Documentation Index
> Fetch the complete documentation index at: https://gologin.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AIエージェントでWeb Unlockerを使う

> Gologin Web UnlockerをAIエージェントやLLMパイプラインのスクレイピングツールとして使う方法

Gologin Web Unlockerは、任意のURLについて完全にレンダリングされたHTMLを返すスクレイピングAPIです。AIエージェントにとっては、ブラウザの制御を組まなくても、ページごとにHTTPリクエストを1回送るだけで安定してWebにアクセスできるということです。

> [!TIP]
>
> **コードを書きたくない場合は** [Web Access CLI](https://gologin.com/docs/ja/cli-tools/web-access.md) または [Scraping Skill](https://gologin.com/docs/ja/api-reference/ai-integrations/ai-skills.md) を使うと、エージェントにすぐスクレイピング機能を追加できます。

***

## ページの内容をLLMに渡す

ページをスクレイピングし、取得したHTMLをモデルに渡して、情報の抽出、要約、分析を行います。パース処理を書く必要はありません。

### Python + Claude

```python theme={null}
import requests
import anthropic

html = requests.get(
    "https://parsing.webunlocker.gologin.com/v1/scrape",
    params={"url": "https://news.ycombinator.com"},
    headers={"apikey": "YOUR_API_KEY"}
).text

client = anthropic.Anthropic()
message = client.messages.create(
    model="claude-sonnet-4-5-20250514",
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": f"Extract the top 5 story titles and URLs from this HTML:\n\n{html[:8000]}"
        }
    ]
)

print(message.content[0].text)
```

### JavaScript + Claude

```javascript theme={null}
import Anthropic from "@anthropic-ai/sdk";

const html = await fetch(
  "https://parsing.webunlocker.gologin.com/v1/scrape?url=" +
    encodeURIComponent("https://news.ycombinator.com"),
  { headers: { apikey: "YOUR_API_KEY" } }
).then((r) => r.text());

const client = new Anthropic();
const message = await client.messages.create({
  model: "claude-sonnet-4-5-20250514",
  max_tokens: 1024,
  messages: [
    {
      role: "user",
      content: `Extract the top 5 story titles and URLs from this HTML:\n\n${html.slice(0, 8000)}`,
    },
  ],
});

console.log(message.content[0].text);
```

***

## エージェントにスクレイピングツールを持たせる

Web Unlockerを利用する `scrape` ツールを定義します。どのタイミングでページを取得するか、どのURLをスクレイピングするかは、エージェントが判断します。

```python theme={null}
import requests
import anthropic

def scrape(url: str) -> str:
    """Fetch a URL and return its rendered HTML."""
    return requests.get(
        "https://parsing.webunlocker.gologin.com/v1/scrape",
        params={"url": url},
        headers={"apikey": "YOUR_API_KEY"}
    ).text

tools = [
    {
        "name": "scrape",
        "description": "Fetch the rendered HTML of any URL, including JavaScript-heavy and protected sites.",
        "input_schema": {
            "type": "object",
            "properties": {
                "url": {"type": "string", "description": "The URL to scrape"}
            },
            "required": ["url"]
        }
    }
]

client = anthropic.Anthropic()
messages = [
    {"role": "user", "content": "What is the current price of the iPhone 16 Pro on apple.com?"}
]

while True:
    response = client.messages.create(
        model="claude-sonnet-4-5-20250514",
        max_tokens=1024,
        tools=tools,
        messages=messages
    )

    if response.stop_reason == "end_turn":
        print(response.content[0].text)
        break

    tool_results = []
    for block in response.content:
        if block.type == "tool_use" and block.name == "scrape":
            html = scrape(block.input["url"])
            tool_results.append({
                "type": "tool_result",
                "tool_use_id": block.id,
                "content": html[:10000]
            })

    messages.append({"role": "assistant", "content": response.content})
    messages.append({"role": "user", "content": tool_results})
```

スクレイピングを行うタイミングや取得するURLはエージェントが判断し、Web Unlockerが取得処理を担当します。JavaScriptのレンダリング、ボット対策の回避、プロキシのローテーション、CAPTCHAの解決まで対応します。

***

## Web Unlocker SDKを使う

TypeScript/Node.jsのエージェント向けに、`gologin-webunlocker` SDKが型付きのメソッドを提供しています。

```ts theme={null}
import { WebUnlocker } from "gologin-webunlocker";

const client = new WebUnlocker({
  apiKey: process.env.GOLOGIN_WEBUNLOCKER_API_KEY!
});

// get structured metadata instead of raw HTML
const { data } = await client.scrapeJSON("https://example.com");
console.log(data.title, data.description, data.headings);

// get clean text for LLM context
const { text } = await client.scrapeText("https://example.com");

// batch scrape with concurrency control
const results = await client.batchScrape(
  ["https://example.com/1", "https://example.com/2", "https://example.com/3"],
  { concurrency: 3 }
);
```

すべてのメソッドについては、[Web Unlocker SDKリファレンス](https://gologin.com/docs/ja/scraping-api-sdk-and-cli.md)をご覧ください。

***

## CLIを使う

Claude Codeのようにシェルコマンドを実行するエージェントには、CLIを使うのが最も簡単です。

```bash theme={null}
# plain text — good for LLM context
gologin-web-access scrape-text https://example.com

# structured JSON — title, description, headings, links
gologin-web-access scrape-json https://example.com

# batch scrape — many pages at once
gologin-web-access batch-scrape url1 url2 url3 --format text --summary

# search the web
gologin-web-access search "best antidetect browser 2026" --limit 10

# extract structured data with a schema
gologin-web-access extract https://example.com --schema ./schema.json
```

すべてのコマンドについては、[Web Access CLIリファレンス](https://gologin.com/docs/ja/cli-tools/web-access.md)をご覧ください。

***

## エージェントの代表的な活用パターン

| パターン | 方法 |
| - | - |
| リサーチエージェント | エージェントが `scrape` ツールを呼び出す → ページを読む → 調査結果をまとめる |
| 価格モニタリング | 商品ページを定期的に `batch-scrape` する → 前回の結果と比較する |
| 競合調査 | 競合サイトを `crawl` する → LLMに渡して分析する |
| リードエンリッチメント | 企業ページを `scrape-json` する → 構造化データを抽出する |
| コンテンツ集約 | `search` + `scrape-text` → キュレーションされたフィードを作成する |

***

## 関連ページ

* [Web Unlockerとは](https://gologin.com/docs/ja/what-is-web-unlocker.md) — 製品の概要と料金
* [Web Unlocker SDK](https://gologin.com/docs/ja/scraping-api-sdk-and-cli.md) — TypeScript SDKリファレンス
* [Web Access CLI](https://gologin.com/docs/ja/cli-tools/web-access.md) — 統合CLI
* [AI Skills](https://gologin.com/docs/ja/api-reference/ai-integrations/ai-skills.md) — Claude Code向けのすぐに使えるスキル


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.