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

# 快速入门

本指南介绍如何使用 Web Unlocker 抓取你的第一个 URL。

***

## 前提条件

* Web Unlocker API 密钥(请联系 **[ermakova.t@gologin.com](mailto:ermakova.t@gologin.com)** 获取)
* Python 3.x、Node.js 或任意 HTTP 客户端

***

## 身份验证

所有请求都需要在 `apikey` 请求头中携带你的 API 密钥:

```
apikey: YOUR_API_KEY
```

所有 API 请求的基础 URL 为:

```
https://parsing.webunlocker.gologin.com/v1
```

***

## 发送第一个请求

发送 GET 请求,并将目标 URL 作为查询参数传入。响应内容为页面完整渲染后的 HTML。

### cURL

```bash theme={null}
curl "https://parsing.webunlocker.gologin.com/v1/scrape?url=https%3A%2F%2Fexample.com" \
  -H "apikey: YOUR_API_KEY"
```

### Python

```python theme={null}
import requests

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

print(response.text)
```

### JavaScript (Node.js / Browser)

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

const html = await response.text();
console.log(html);
```

***

## 返回结果

响应正文是页面渲染后的原始 HTML,与你在浏览器中打开该 URL 时看到的内容相同。没有 JSON 封装,也无需额外解析。

```html theme={null}
<!DOCTYPE html>
<html>
  <head><title>Example Domain</title></head>
  <body>...</body>
</html>
```

***

## 错误处理

处理响应之前,请先检查 HTTP 状态码:

| 状态码 | 含义 |
| - | - |
| `200` | 成功——响应正文为页面 HTML |
| `401` | API 密钥无效或缺失 |
| `422` | URL 参数无效或缺失 |
| `429` | 超出速率限制 |
| `500` / `503` | 服务器错误——请使用退避策略重试 |

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

if response.status_code == 200:
    html = response.text
else:
    print(f"Error {response.status_code}: {response.text}")
```

***

## 使用 CLI 快速开始

你也可以使用 Gologin CLI 工具抓取页面,无需编写代码:

### Web Unlocker CLI

```bash theme={null}
npm install -g gologin-webunlocker

GOLOGIN_WEBUNLOCKER_API_KEY=wu_... gologin-webunlocker scrape https://example.com
GOLOGIN_WEBUNLOCKER_API_KEY=wu_... gologin-webunlocker text https://example.com
GOLOGIN_WEBUNLOCKER_API_KEY=wu_... gologin-webunlocker markdown https://example.com
```

### Gologin Web Access CLI(统一版)

```bash theme={null}
npm install -g gologin-web-access

export GOLOGIN_WEB_UNLOCKER_API_KEY="wu_..."
gologin-web-access read https://example.com
gologin-web-access scrape-json https://example.com
gologin-web-access batch-scrape https://example.com/page/1 https://example.com/page/2 --format text
```

更多详情请参阅 [Web Unlocker SDK 和 CLI](https://gologin.com/docs/zh/scraping-api-sdk-and-cli.md) 以及 [Web Access CLI](https://gologin.com/docs/zh/cli-tools/web-access.md)。


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