> ## 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.

# Các trường hợp sử dụng Web Unlocker

Web Unlocker là một scraping API — bạn gửi một URL và nhận lại HTML đã được hiển thị đầy đủ. Trang này giới thiệu những cách sử dụng phổ biến nhất.

***

## Tự thu thập dữ liệu một trang

Trường hợp đơn giản nhất: bạn cần lấy nội dung của một trang web chặn các yêu cầu HTTP thông thường.

### Python

```python theme={null}
import requests

response = requests.get(
    "https://parsing.webunlocker.gologin.com/v1/scrape",
    params={"url": "https://example.com/product/123"},
    headers={"apikey": "YOUR_API_KEY"}
)

html = response.text
print(html)
```

### JavaScript

```javascript theme={null}
const html = await fetch(
  "https://parsing.webunlocker.gologin.com/v1/scrape?url=" +
    encodeURIComponent("https://example.com/product/123"),
  { headers: { apikey: "YOUR_API_KEY" } }
).then((r) => r.text());

console.log(html);
```

Không cần khởi chạy trình duyệt, không cần cấu hình proxy, không phải vật lộn với Cloudflare. Chỉ một lệnh gọi là bạn có được trang web.

**Phù hợp để:**

* Kiểm tra giá trên trang của đối thủ cạnh tranh
* Lấy danh sách việc làm, đánh giá hoặc dữ liệu sản phẩm
* Theo dõi sự thay đổi của các trang
* Viết các script thu thập dữ liệu dùng một lần

***

## Đưa nội dung vào AI

Web Unlocker trả về HTML thô. Hãy chuyển HTML đó cho một LLM để trích xuất dữ liệu có cấu trúc, tóm tắt nội dung hoặc trả lời các câu hỏi về trang — không cần viết logic phân tích cú pháp.

### Python + OpenAI

```python theme={null}
import requests
from openai import OpenAI

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

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {
            "role": "user",
            "content": f"Extract the top 5 story titles and their URLs from this HTML:\n\n{html[:8000]}"
        }
    ]
)

print(response.choices[0].message.content)
```

### JavaScript + Anthropic

```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-opus-4-5",
  max_tokens: 1024,
  messages: [
    {
      role: "user",
      content: `Extract the top 5 story titles and their URLs from this HTML:\n\n${html.slice(0, 8000)}`,
    },
  ],
});

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

**Phù hợp để:**

* Trích xuất dữ liệu có cấu trúc (giá, tên, ngày tháng) mà không cần viết trình phân tích cú pháp
* Tóm tắt bài viết hoặc trang sản phẩm
* So sánh nhiều trang và rút ra kết luận
* Xây dựng các công cụ nghiên cứu hoặc giám sát được vận hành bằng AI

***

## Sử dụng trong một AI agent

Hãy cung cấp cho AI agent của bạn một công cụ `scrape` dựa trên Web Unlocker. Khi đó, agent có thể tự duyệt web — tải trang, đọc nội dung và thực hiện hành động — mà bạn không cần viết bất kỳ logic duyệt web nào.

```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-opus-4-5",
        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})
```

Agent tự quyết định khi nào cần thu thập dữ liệu và tải URL nào. Web Unlocker đảm nhận việc lấy dữ liệu thực tế.

**Phù hợp để:**

* Các agent nghiên cứu tự động duyệt web
* Bot so sánh giá hoặc tìm ưu đãi
* Các quy trình thu thập thông tin cạnh tranh
* Bất kỳ agent nào cần dữ liệu web theo thời gian thực

***

## Thu thập nhiều trang cùng lúc

Chạy các yêu cầu đồng thời để thu thập dữ liệu từ nhiều URL song song.

```python theme={null}
import requests
from concurrent.futures import ThreadPoolExecutor

API_URL = "https://parsing.webunlocker.gologin.com/v1/scrape"
API_KEY = "YOUR_API_KEY"

urls = [
    "https://example.com/page/1",
    "https://example.com/page/2",
    "https://example.com/page/3",
]

def scrape(url):
    response = requests.get(
        API_URL,
        params={"url": url},
        headers={"apikey": API_KEY}
    )
    return url, response.text

with ThreadPoolExecutor(max_workers=5) as executor:
    results = list(executor.map(scrape, urls))

for url, html in results:
    print(f"{url}: {len(html)} chars")
```

**Phù hợp để:**

* Thu thập toàn bộ danh mục sản phẩm hoặc các trang danh sách
* Thu thập dữ liệu hàng loạt để tạo bộ dữ liệu huấn luyện
* Theo dõi nhiều trang cùng lúc

***

## Tóm tắt

| Trường hợp sử dụng | Bạn làm gì | Bạn nhận được gì |
| - | - | - |
| Thu thập một trang | GET kèm tham số URL | HTML đã hiển thị |
| Đưa vào LLM | Thu thập → chuyển cho mô hình | Dữ liệu đã trích xuất hoặc bản tóm tắt |
| Công cụ cho AI agent | Agent gọi khi cần | Nội dung web theo thời gian thực |
| Thu thập hàng loạt | Các yêu cầu đồng thời | HTML cho từng URL |

***

## Sử dụng từ CLI

Bạn không cần viết code — hãy dùng Gologin Web Access CLI cho các quy trình thu thập dữ liệu phổ biến:

```bash theme={null}
npm install -g gologin-web-access
export GOLOGIN_WEB_UNLOCKER_API_KEY="wu_..."

# batch scrape multiple pages
gologin-web-access batch-scrape \
  https://example.com/page/1 \
  https://example.com/page/2 \
  https://example.com/page/3 \
  --format text --only-main-content --summary

# crawl a site
gologin-web-access crawl https://docs.example.com --format markdown --limit 50 --max-depth 2

# monitor page changes
gologin-web-access change-track https://example.com/pricing --format markdown

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

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

Xem [Web Access CLI](https://gologin.com/docs/vi/cli-tools/web-access.md) để biết đầy đủ danh sách lệnh.

***

## Tóm tắt

| Trường hợp sử dụng | Bạn làm gì | Bạn nhận được gì |
| - | - | - |
| Thu thập một trang | GET kèm tham số URL | HTML đã hiển thị |
| Đưa vào LLM | Thu thập → chuyển cho mô hình | Dữ liệu đã trích xuất hoặc bản tóm tắt |
| Công cụ cho AI agent | Agent gọi khi cần | Nội dung web theo thời gian thực |
| Thu thập hàng loạt | Các yêu cầu đồng thời | HTML cho từng URL |
| Quy trình CLI | Các lệnh `gologin-web-access` | Văn bản, markdown, JSON, kết quả hàng loạt |

Xem [Bắt đầu nhanh](https://gologin.com/docs/vi/web-unlocker-quick-start.md) để thực hiện yêu cầu đầu tiên của bạn.


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